eclipse-paho / paho.mqtt.cpp

Other
1.03k stars 438 forks source link

No consumer notification when broker cleanly disconnects #458

Closed fpagliughi closed 3 months ago

fpagliughi commented 11 months ago

When a consumer application is receiving messages from a queue, it gets a null/empty message pointer when the client is unexpectedly disconnected from the broker.

But this notification does not arrive if the broker cleanly disconnects from the client by sending a DISCONNECT packet

fpagliughi commented 11 months ago

Remember on_connection_lost() is fired when the connection is unexpectedly lost, but it's on_disconnected() that fires on a clean disconnect from the broker.

fpagliughi commented 11 months ago

It appears that there is also an upstream issue affecting this... https://github.com/eclipse/paho.mqtt.c/issues/1419

fpagliughi commented 11 months ago

Pushed this back to v1.4 release to allow the upstream issue to resolve.

fpagliughi commented 3 months ago

Found it... the call to start_consuming() was not registering the 'on_disconnected' handler.

The fix is in the v1.4.x branch and will go out with v1.4.1 and v1.5