Skip to content

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Jul 24, 2022

We built bleak-retry-connector for aiohomekit to handle the transient errors that happen when using bleak with dbus since
we were missing disconnected events. As switchbots seem to fail in the same way with bleak on dbus, using the library
made the problem go away.

Also, the default connect timeout is too low which means services cannot be resolved in time so it disconnects in the middle of the connection leaving things in a bad state which is likely why the retry timeout option was added. Although it might have been added for not finding the device via discovery and then added to the client path as well. It makes sense in the scanner path since sometimes the device can fall out of the list, but shouldn't be needed in the client path as long as the connect timeout doesn't cause a disconnect in the middle of services being resolved which the current low timeout will do.

The short version is we don't count transient errors as needing to wait, and since they seem to happen often, it makes the action quite a bit faster if we hit a transient one as we try again right away instead of sleeping.

This should also fix the issue reported here #48 (comment)

2022-07-23 21:53:42.549 DEBUG (MainThread) [bleak_retry_connector] FD:60:30:55:92:57: WoHand: Connecting (attempt: 1)
2022-07-23 21:53:44.820 DEBUG (MainThread) [bleak_retry_connector] FD:60:30:55:92:57: WoHand: Failed to connect: [org.bluez.Error.Failed] le-connection-abort-by-local (attempt: 1)
2022-07-23 21:53:44.820 DEBUG (MainThread) [bleak_retry_connector] FD:60:30:55:92:57: WoHand: Connecting (attempt: 2)
2022-07-23 21:53:45.843 DEBUG (MainThread) [bleak_retry_connector] FD:60:30:55:92:57: WoHand: Failed to connect: [org.bluez.Error.Failed] le-connection-abort-by-local (attempt: 2)
2022-07-23 21:53:45.843 DEBUG (MainThread) [bleak_retry_connector] FD:60:30:55:92:57: WoHand: Connecting (attempt: 3)
2022-07-23 21:53:47.544 DEBUG (MainThread) [bleak_retry_connector] FD:60:30:55:92:57: WoHand: Connected (attempt: 3)

We built bleak-retry-connector for aiohomekit to handle the
transient errors that happen when using bleak with dbus since
we were missing disconnected events. As switchbots seem to
fail in the same way with bleak on dbus, using the library
made the problem go away
@Danielhiversen Danielhiversen merged commit aaed98b into sblibs:master Jul 24, 2022
@bdraco
Copy link
Member Author

bdraco commented Jul 24, 2022

Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants