Bluetooth-Library icon indicating copy to clipboard operation
Bluetooth-Library copied to clipboard

connection error

Open sontqq opened this issue 5 years ago • 10 comments

Everytime I try to connect to a device i get:

error_read failed, socket might closed or timeout, read ret: -1

Any idea?

sontqq avatar Jun 05 '19 13:06 sontqq

What kind of the device are you trying to connect to ?

Take a look at this README section : https://github.com/OmarAflak/Bluetooth-Library/blob/master/README.md#connect-to-device-using-port-trick

omaraflak avatar Jun 05 '19 13:06 omaraflak

I'm trying to connect from an Android 9.0 Samsung device to a Windows 10 PC with a bluetooth dongle.

I have also tried to connect with the port tricking but no success.

sontqq avatar Jun 05 '19 17:06 sontqq

I get this error:

W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'android.bluetooth.BluetoothSocket android.bluetooth.BluetoothDevice.createRfcommSocketToServiceRecord(java.util.UUID)' on a null object reference
        at me.aflak.bluetooth.Bluetooth.connect(Bluetooth.java:462)
W/System.err:     at me.aflak.bluetooth.Bluetooth.connectToDevice(Bluetooth.java:271)
        at me.aflak.bluetooth.Bluetooth.connectToDevice(Bluetooth.java:279)
W/System.err:     at com.sontme.esp.getlocation.activities.MainActivity$3$2.onDiscoveryFinished(MainActivity.java:363)
        at me.aflak.bluetooth.Bluetooth$7$3.run(Bluetooth.java:597)
        at me.aflak.bluetooth.utils.ThreadHelper.run(ThreadHelper.java:15)
W/System.err:     at me.aflak.bluetooth.Bluetooth$7.onReceive(Bluetooth.java:594)
        at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1486)
        at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2)
        at android.os.Handler.handleCallback(Handler.java:873)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7073)
W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)

sontqq avatar Jun 06 '19 18:06 sontqq

I'm having the same error, using either connectToDevice and connectToDeviceWithPortTrick, but fails every time. I downloaded the Bluetooth Terminal app and it logs the same error on the screen. I tried to connect from a Pixel 3 (Android 10) to a Galaxy J5 Pro (Android 9).

jpeiter avatar May 19 '20 23:05 jpeiter

yep, same for me, trying to connect to medical device, but it is saying same, error_read failed, socket might closed or timeout, read ret: -1

glebkravchenko avatar Aug 20 '20 13:08 glebkravchenko

Please make sure you are using a regular Bluetooth dongle, not BLE. BLE is not supported.

omaraflak avatar Aug 20 '20 13:08 omaraflak

I'm getting this msg too. Is there any solution? Is there any way to disable BLE @OmarAflak?

charlieporth1 avatar Dec 20 '21 16:12 charlieporth1

This issue is still persistent, is there a workaround for this, none of the other libraries are also able to tackle this.

ibrahim-iqbal avatar Jan 10 '22 11:01 ibrahim-iqbal

Everytime I try to connect to a device i get:

error_read failed, socket might closed or timeout, read ret: -1

Any idea?

no

skillhubz avatar Oct 16 '23 04:10 skillhubz

Please make sure you are using a regular Bluetooth dongle, not BLE. BLE is not supported.

gotcha

skillhubz avatar Oct 16 '23 04:10 skillhubz