BluetoothSocket.connect() throwing exception "read failed"

In my case it was due to bad UUID in createRfcommSocketToServiceRecord() function. I want to connect to SPP serial profile in raspberry pi 3 and I used this UUID:

private static final UUID MY_UUID_SECURE =
            UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");

I found somewhere in android documents' page for SPP.


I know this is kind of an old question. But as I was not able to find any solution on the web, here is a workaround I recently have created: IOException: read failed, socket might closed - Bluetooth on Android 4.3


Jellybean has a completely different Bluetooth stack, so version differences could certainly be triggering something, but that in itself wouldn't explain why it stays working or not-working after connecting with an older device. Could it be to do with pairing? If it happens again, try unpairing from the device and pairing again.