Hi,
Thank you for trio-paho-mqtt!
Following the pattern in the README.md example, I did something equivalent to:
async with trio.open_nursery() as nursery:
sync_client = mqtt.Client()
client = AsyncClient(sync_client, nursery)
client.connect(...)
client.subscribe(topic)
async for message in client.messages():
...
However I seemed to stop receiving messages after a while. I think this is because the connection timed out, the (sync) client reconnected automatically, but the subscription wasn't recreated.
https://github.com/eclipse/paho.mqtt.python/blob/master/README.rst says:
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
# Subscribing in on_connect() means that if we lose the connection and
# reconnect then subscriptions will be renewed.
client.subscribe("$SYS/#")
However I can't straightforwardly do this in trio-paho-mqtt because you're already using the sync client on_connect method for internal purposes, and aren't exposing that to the API user.
I wonder if you could provide on_connect functionality directly from AsyncClient please?
Hi,
Thank you for trio-paho-mqtt!
Following the pattern in the
README.mdexample, I did something equivalent to:However I seemed to stop receiving messages after a while. I think this is because the connection timed out, the (sync) client reconnected automatically, but the subscription wasn't recreated.
https://github.com/eclipse/paho.mqtt.python/blob/master/README.rst says:
However I can't straightforwardly do this in trio-paho-mqtt because you're already using the sync client
on_connectmethod for internal purposes, and aren't exposing that to the API user.I wonder if you could provide
on_connectfunctionality directly fromAsyncClientplease?