Replies: 5 comments
-
Hi there, thanks for opening this issue! 🙂 We recommend to always use the |
Beta Was this translation helpful? Give feedback.
-
@empicano I‘m working on IOT, and there are some iot connectors such as modbus, bluetooh, mqtt, etc. I want to make them have the same behavior, which should have open, close, send, receive... |
Beta Was this translation helpful? Give feedback.
-
When I run your script, I get Btw. you can paste code into GitHub comments by surrounding it with triple backticks (```), that makes it a lot faster for me to help you than when I'm juggling with zip files and screenshots 😉 |
Beta Was this translation helpful? Give feedback.
-
@empicano thanks for your reply. When subscribing to a topic, messages will be queued internally, but I usually use diskcache lib for message persistence other than asyncio queues, if there's way to implement it? |
Beta Was this translation helpful? Give feedback.
-
At the moment, aiomqtt only supports asyncio queues. You could relay the messages with something like this: async with Client("test.mosquitto.org") as client:
await client.subscribe("temperature/#")
async for message in client.messages:
... # Put the message into diskcache here, then consume it from somewhere else I'll convert this into a discussion, maybe someone else has done something similar 🙂 |
Beta Was this translation helpful? Give feedback.
-
hi, if I don't use the "with" statement, how to open and close the mqtt client? I try to use aenter and aexit, but rasie some error. Below is my test script.
mqtt_connector.zip
Beta Was this translation helpful? Give feedback.
All reactions