Skip to content

Commit

Permalink
Merge pull request #227 from kpfleming/fix-reconnection
Browse files Browse the repository at this point in the history
Detect disconnections during poll() calls
  • Loading branch information
krkeegan authored Dec 11, 2020
2 parents 774f348 + 292db9d commit cb6726c
Showing 1 changed file with 4 additions and 2 deletions.
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

0 comments on commit cb6726c

Please sign in to comment.