api: implement automatic mqtt reconnect in ccujack cron
All checks were successful
Build Container / Build Container (push) Successful in 1m27s
All checks were successful
Build Container / Build Container (push) Successful in 1m27s
This commit is contained in:
parent
319670b6ae
commit
6bbfc5dc68
2 changed files with 12 additions and 1 deletions
|
|
@ -154,8 +154,16 @@ class AsyncMqttClient:
|
|||
|
||||
await self.fut_connected
|
||||
|
||||
# re-establish all supposed mqtt subscriptions
|
||||
if len(self.active_subscriptions > 0):
|
||||
qos = 1
|
||||
await self.client.subscribe((i, qos) for i in self.active_subscriptions)
|
||||
|
||||
async def disconnect(self):
|
||||
logger.info("Disconnecting mqtt client from broker")
|
||||
self.fut_disconnect = asyncio.get_running_loop().create_future()
|
||||
self.client.disconnect()
|
||||
await self.fut_disconnect
|
||||
|
||||
def is_connected(self) -> bool:
|
||||
return self.client.is_connected()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue