-
Notifications
You must be signed in to change notification settings - Fork 52
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
Subscribe/close throws exception #58
Comments
Hi, I'm sorry for the late reply, but here it is: Checking the connection is alive before doing something can be a fail-fast optimization, but other than that, it cannot prevent sudden connection drops, so checking the connection somehow before using it would only reduce occurrences of that behavior. I'll take a look at your PR soon, still. |
For what it's worth, @grubesa's change was a big help to me. I have a situation where the device can suddenly go out of range, so graceful disconnects are not an option. |
Hello, I finally released a new version (after almost 3 years 😓 ), it's on MavenCentral and should avoid un-preventable crashes like this one. BTW, BleGattCoroutines is, as you'd expect, now on MavenCentral. |
Hi,
I think I found a bug. It occurs in following situation:
When I subscribe to characteristic with
connection.openNotificationSubscription(notificationCharacteristic)
andconnection closes before I get the chance to unsubscribe from characteristic. I get this exception:
While investigating, I realised that you attach close handler to notifications channel which causes the exception:
setCharacteristicNotificationsEnabled(characteristic, enable = false)
will fail if device is not connected.I also realise that you have
disableNotificationsOnChannelClose
flag which could handle this case, but I don't think that would be the right way to handle my use case. In my case, remote device suddenly initiates (unexpected) connection close which triggers this exception.I think this exception shouldn't happen, library should check if connection is alive before calling
setCharacteristicNotificationsEnabled(characteristic, enable = false)
.I posted a PR with my proposed solution.
You can reproduce this bug very easily:
The text was updated successfully, but these errors were encountered: