paho.mqtt.python icon indicating copy to clipboard operation
paho.mqtt.python copied to clipboard

Publishing Message fails if Program exits directly after

Open Remolade01 opened this issue 3 years ago • 1 comments

Calling client.publish(topic, payload, qos=0) results in the message being handled as sent (client.on_publish function is executed) But if the python script ends after the publish call, the message does not get sent. Adding a time.sleep(1) after client.publish(...) consistently sends the message.

Remolade01 avatar Aug 11 '23 09:08 Remolade01

If you want to publish a message and ensure it's left the client before exiting then use single. The library queues publish requests so 'Publish` is likely to return before the message is actually sent.

Closing this for now - if you still have an issue then feel free to reopen but please provide a full example.

MattBrittan avatar Dec 24 '23 01:12 MattBrittan