You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want integrate message from mqtt to flet web. I tried add line
await ft.app_async(main) in while True cycle. But it works like sync mode. Please help me.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Question
Hi. im using async mqtt library
https://github.com/sbtinstruments/aiomqtt
Sample of my code:
I want integrate message from mqtt to flet web. I tried add line
await ft.app_async(main) in while True cycle. But it works like sync mode. Please help me.
Code sample
https://github.com/sbtinstruments/aiomqtt/blob/main/docs/reconnection.md
import asyncio
import aiomqtt
async def main():
client = aiomqtt.Client("test.mosquitto.org")
interval = 5 # Seconds
while True:
try:
async with client:
async with client.messages() as messages:
await client.subscribe("humidity/#")
async for message in messages:
print(message.payload)
except aiomqtt.MqttError:
print(f"Connection lost; Reconnecting in {interval} seconds ...")
await asyncio.sleep(interval)
asyncio.run(main())
Error message
No response
------------------------------------------------------
Beta Was this translation helpful? Give feedback.
All reactions