publish() and then disconnect() may result in messages not received by a broker · Issue #139 · wialon/gmqtt · GitHub
More Web Proxy on the site http://driver.im/
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
We have such code (simplified): client = MQTTClient(instance_name, session_expiry_interval=0, clean_session=True) await client.connect(broker_addr) client.publish("theMessage", qos=1, retain=True) # we possibly send here much more messages await asyncio.sleep(4) # wait for publish msgs to be sent; 2 secs is not enough, 4 is enough (update: or not) await client.disconnect() sys.exit(0)
problem is with the sleep; without the sleep, "theMessage" (and/or subsquently sent messsages) is not received by the broker. Recently, sleep with even 4 seconds is not enough.
Is there a better way to wait for the queued messages to be received by the broker, before making a disconnect?
The text was updated successfully, but these errors were encountered:
Hi.
We have such code (simplified):
client = MQTTClient(instance_name, session_expiry_interval=0, clean_session=True)
await client.connect(broker_addr)
client.publish("theMessage", qos=1, retain=True)
# we possibly send here much more messages
await asyncio.sleep(4) # wait for publish msgs to be sent; 2 secs is not enough, 4 is enough (update: or not)
await client.disconnect()
sys.exit(0)
problem is with the sleep; without the sleep, "theMessage" (and/or subsquently sent messsages) is not received by the broker. Recently, sleep with even 4 seconds is not enough.
Is there a better way to wait for the queued messages to be received by the broker, before making a disconnect?
The text was updated successfully, but these errors were encountered: