-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IOException: read failed, socket might closed or timeout, read ret: -1 #164
Comments
@AgainPsychoX can you please help me out in this? Any help will be highly appreciated. Thanks |
@AgainPsychoX can you please help me out in this? Any help will be highly appreciated. Thanks |
@RRohitM are you also facing the same issue? What's the occurrence pattern of the issue? |
Hello @vaibhiarora03 please replace this code i have resolve this error You can change BluetoothConnection.java class /// Connects to given device by hardware address (default UUID used) |
Hi @RRohitM thanks for sharing your input. The nature and occurrence of this issue is something different for me. Were you facing a complete blockage with this error or was the error-case like mine? Regards |
I've been facing this issue while connecting OBDII devices. This issue's occurrence is very random varied across cheap Chinese OBD devices to expensive branded ones.
For Bluetooth communication in flutter, I'm using the Flutter Bluetooth Serial package https://pub.dev/packages/flutter_bluetooth_serial
What I'm doing is initially creating a socket via
createRfcommSocketToServiceRecord
method. When IOException occurs, then the socket is created viacreateRfcommSocket
reflection method. If still, the IOException occurs, then the Input and Output streams and socket are closed manually and then the connection is tried again. I try connection a total of 3 times.Here is the
connect
function which I changed in the package.reconnectSocket
is the function in which the Input and Output streams and Socket is closed manually and connection is tried again.I've tried changing the channel value for the port ranging from 1-5 for the reflection method.
Port-1:- Most of the time the connection gets created.
Port-2:- As soon as the device gets connected, it gets disconnected.
Port-3:- Device gets connected but unexpected responses are received.
Port-4:- java.io.IOException: bt socket closed, read return: -1
Port-5:- java.io.IOException: bt socket closed, read return: -1
How do we figure out that port number has to be used for creating the connection via the reflection method?
Previously we had faced a similar kind of issue with the native android app and the issue was resolved with the help of the exact same methods which I've mentioned above.
With all the possible tries, now ran out of ideas. Any help will be very much appreciated.
Thanks
The text was updated successfully, but these errors were encountered: