-
Notifications
You must be signed in to change notification settings - Fork 8
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
Exception: Read failed, socket might closed or timeout, read ret: -1 #3
Comments
Did you create a new connection instance on each click or reusing the same connection? |
Hello. |
I see. But, how properly close, remove this connection? because, if I'm testing and relaunch app connection will receive error |
I looked into my code and found that I put ManagedBluetoothConnection into the App level. And on appear event it closing the connection if it opened. P.S. I used Samsung Galaxy Note 9 with Android 10 to test. protected override async void OnAppearing()
{
RefreshUI();
await DisconnectIfConnectedAsync();
}
private async Task DisconnectIfConnectedAsync()
{
if (App.CurrentBluetoothConnection != null)
{
try
{
App.CurrentBluetoothConnection.Dispose();
}
catch (Exception exception)
{
await DisplayAlert("Error", exception.Message, "Close");
}
}
} |
Also, did you try this example: https://github.com/rostislav-nikitin/Plugin.BluetoothClassic/tree/master/examples/Digit/Digit |
Need to test. |
For the managed connection I think, after you closed the connection, you need again select the device (new instance) from the bounded devices and then try to create a new connection for a newly selected device. About response bytes: It accepts a reference to the response buffer as a bytes array, offset and count of bytes to receive and yep, it returns int - the real cont of bytes received. This is documentation to other methods: https://github.com/rostislav-nikitin/Plugin.BluetoothClassic#ibluetoothconnection-idisposable |
Hi, I'am trying to send data to device when user click a button. First time everything is OK. But, when I click the button second time, I receive IOException exception with message "Read failed, socket might closed or timeout, read ret: -1". The problem is in bluetoothSocket.connect(); function. It's android problem after android 4.2.
The text was updated successfully, but these errors were encountered: