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
There are some cases when the client disconnects and then reconnects. the application can handle these drops, so we do not crash out or throw any exception.
The Issue is that we are able to publish messages but not receive any messages after the reconnection. I am not sure if there is a need to resubscribe to the topics again after this disconnect event [-3]
The text was updated successfully, but these errors were encountered:
mayur-IG
changed the title
Is there a need to resubscribe to topics in async client when disconnect event [-3] occurs.
Is there a need to resubscribe to topics in async client clean_session(false) when disconnect event [-3] occurs.
Jul 26, 2024
No, whether the session is still present has nothing to do with the KEEP_ALIVE_INTERVAL.
Since you are setting clean_session to false, you're telling the server to keep a persistent session for your client. Although you don't show the client construction, I assume that you're setting a unique Client ID, and reusing the same ID when you reconnect. The server tracks the session by Client ID.
With MQTT v5 there is a session expiry interval property that goes in the connect packet. This tells the server how long to keep the session after the client disconnects. You can tell it to keep the session active for an hour, day, week; whatever.
With MQTT v3 (which you appear to be using), the session is supposed to stay "forever". This was a mistake in the protocol design, because clients could connect, request a session, then disconnect and never be seen again. In which case the server accumulated all their messages forever. Because of this, many v3 servers have a configured expiry interval, after which they will discard the session.
While using Async Client [paho-mqttpp3 paho-mqtt3as] with automatic_reconnect example connection options below:
There are some cases when the client disconnects and then reconnects. the application can handle these drops, so we do not crash out or throw any exception.
The Issue is that we are able to publish messages but not receive any messages after the reconnection. I am not sure if there is a need to resubscribe to the topics again after this disconnect event [-3]
The text was updated successfully, but these errors were encountered: