• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps java.io.IOException: read failed, socket might closed or timeout, read ret: -1 on Android 5.0 and ab

I am making a Bluetooth connection to a device. I have used this library for connection.

It gives problem in Android 5.0 and above specially when the screen the is locked. I get the following error in logcat

07-03 10:12:04.440: W/art(17213): Suspending all threads took: 5.433ms 07-03 10:12:05.970: W/art(17213): Suspending all threads took: 5.511ms 07-03 10:12:07.080: W/art(17213): Suspending all threads took: 5.848ms 07-03 10:12:07.820: W/art(17213): Suspending all threads took: 5.818ms 07-03 10:12:08.050: W/art(17213): Suspending all threads took: 132.901ms 07-03 10:12:08.075: W/art(17213): Suspending all threads took: 5.875ms

07-03 10:12:08.140: D/BluetoothSocket(17213): close() in, this: android.bluetooth.BluetoothSocket@2b1e7346, channel: 6, state: CLOSED 07-03 10:12:08.145: D/BluetoothSocket(17213): close() in, this: android.bluetooth.BluetoothSocket@21187e46, channel: 6, state: CONNECTED 07-03 10:12:08.145: D/BluetoothSocket(17213): close() this: android.bluetooth.BluetoothSocket@21187e46, channel: 6, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@3e0b4807, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@1729fd34mSocket: android.net.LocalSocket@323ed75d impl:android.net.LocalSocketImpl@394e38d2 fd:FileDescriptor[75] 07-03 10:12:08.145: D/BluetoothSocket(17213): Closing mSocket: android.net.LocalSocket@323ed75d impl:android.net.LocalSocketImpl@394e38d2 fd:FileDescriptor[75]

After this error I get java.io.IOException: read failed, socket might closed or timeout, read ret: -1 .

I am stuck terribly. Thanks in advance for help.
 
  • Like
Reactions: Peter Tu

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones