mgdm / Mosquitto-PHP

A wrapper for the Eclipse Mosquitto™ MQTT client library for PHP.
BSD 3-Clause "New" or "Revised" License
531 stars 146 forks source link

unsent messages at disconnect #93

Open blacktek opened 6 years ago

blacktek commented 6 years ago

after publish I do one loop() and then a disconnect(), but very often there are unsent messages that get lost.

Is there a clean way to verify if there are still messages in the queue and then iterate a loop() until the queue is empty? I could do this by using a counter to increment at each publish and to decrement at each onPublish, but is not a clean approach

mgdm commented 5 years ago

One loop isn't enough. I'd probably go for the counter option. I don't know offhand of any way to see if there's anything left in flight in the queue, I'll have another look though.