Skip to content
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

Detect disconnections during poll() calls #227

Merged
merged 1 commit into from
Dec 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions insteon_mqtt/network/Mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ def poll(self, t):
passed in so that all clients receive the same "current" time
instead of each calling time.time() and getting a different value.
"""
# This is required to handle keepalive messages.
self.client.loop_misc()
# This is required to handle keepalive messages and detect disconnections.
rc = self.client.loop_misc()
if rc == paho.MQTT_ERR_NO_CONN:
self._on_disconnect(self.client, None, rc)

#-----------------------------------------------------------------------
def retry_connect_dt(self):
Expand Down