8000 publish() and then disconnect() may result in messages not received by a broker · Issue #139 · wialon/gmqtt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

publish() and then disconnect() may result in messages not received by a broker #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dawcal opened this issue Dec 10, 2021 · 0 comments

Comments

@dawcal
Copy link
dawcal commented Dec 10, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0