Abrupt Broker loss leads to shifted command Queue
Simply tested by rebooting the machine where the broker runs (in my case Raspi4 with Mosquito).
An Exception was caused in __init_.py (AssertionError)
I simply solved it by adding the AssertionError to your except block
async def _handle_msg(self):
try:
while self.isconnected():
async with self.lock:
await self.wait_msg() # Immediate return if no message
# https://github.com/peterhinch/micropython-mqtt/issues/166
# A delay > 0 is necessary for webrepl compatibility.
await asyncio.sleep_ms(5) # Let other tasks get lock
except (OSError, AssertionError):
pass
self._reconnect() # Broker or WiFi fail.
1 条评论