Small fixes
Handle more errors, and fix Client.stopListening
This commit is contained in:
@@ -2834,10 +2834,13 @@ class Client(object):
|
||||
|
||||
def stopListening(self):
|
||||
"""Stop the listening loop."""
|
||||
if not self._mqtt:
|
||||
raise ValueError("Not listening")
|
||||
self._mqtt.disconnect()
|
||||
self.listening = False
|
||||
if not self._mqtt:
|
||||
return
|
||||
self._mqtt.disconnect()
|
||||
# TODO: Preserve the _mqtt object
|
||||
# Currently, there's some issues when disconnecting
|
||||
self._mqtt = None
|
||||
|
||||
def listen(self, markAlive=None):
|
||||
"""Initialize and runs the listening loop continually.
|
||||
|
@@ -91,6 +91,12 @@ class Mqtt:
|
||||
if "lastIssuedSeqId" in j:
|
||||
self._sequence_id = j["lastIssuedSeqId"]
|
||||
|
||||
if "errorCode" in j:
|
||||
# Known types: ERROR_QUEUE_OVERFLOW | ERROR_QUEUE_NOT_FOUND
|
||||
# 'F\xfa\x84\x8c\x85\xf8\xbc-\x88 FB_PAGES_INSUFFICIENT_PERMISSION\x00'
|
||||
log.error("MQTT error code %s received", j["errorCode"])
|
||||
# TODO: Consider resetting the sync_token and sequence ID here?
|
||||
|
||||
log.debug("MQTT payload: %s", j)
|
||||
|
||||
# Call the external callback
|
||||
|
Reference in New Issue
Block a user