Use bleak-retry-connector to handle transient connection errors #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)