2

I am attempting to establish an insecure Bluetooth socket connection between two Android devices. I control the software on both ends. One end uses listenUsingInsecureRfcommWithServiceRecord to listen for a connection, the other end uses createInsecureRfcommSocketToServiceRecord to connect. This works. Sometimes.

The "sometimes" is my problem. In about 20% of the attempts, it fails and throws the following exception:

java.io.IOException: Service discovery failed
    at android.bluetooth.BluetoothSocket$SdpHelper.doSdp(BluetoothSocket.java:403)
    at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:213)
    at com.example.bluetoothpoke.MainActivity$1.onClick(MainActivity.java:34)

Both devices are awake with screen on. The distance between the devices is around 1m (10 cm and 3m don't make a difference). Neither device is performing discovery. Both devices are discoverable (making both non-discoverable doesn't change anything, either).

Do I have to assume it is normal because of the wireless interface and just try again on failure, or is there something I can do? Shouldn't it work more reliably given that I am at a very comfortable distance?

Note: I found lots of similar questions, but the ones I found are either about "doesn't work at all", connecting to a non-Android device, or both.

Jan Schejbal
  • 4,000
  • 19
  • 40
  • 20% connection failure is not normal .. Its too high (Unless the bluetooth hardware is of very bad quality) Can you port the logcat bluetooth output from android to see what is causing the failure – Dennis Mathews Feb 01 '13 at 16:55
  • `D/BluetoothService(280): Cleaning up failed UUID channel lookup: xx:xx:xx:xx:xx:xx xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` (the X-ed out values being the target device bluetooth address and the service UUID) is the only thing I see that is different from successful connections. Not very helpful. – Jan Schejbal Feb 02 '13 at 06:18
  • hmm ..cant say much from this snippet – Dennis Mathews Feb 02 '13 at 19:58
  • Hey I have this same issue. Did you find any solution? – nayakasu Oct 03 '17 at 17:40

0 Answers0