-
Notifications
You must be signed in to change notification settings - Fork 437
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
Is there a need to resubscribe to topics in async client clean_session(false) when disconnect event [-3] occurs. #507
Comments
Noticed that the disconnect was longer than KEEP_ALIVE_INTERVAL. maybe this caused the session to clear out. |
No, whether the session is still present has nothing to do with the KEEP_ALIVE_INTERVAL. Since you are setting 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. In either case, when you connect, the server will tell you if it remembers your Client ID and has a "session present". You can get that from the server response to the connect call, as shown in a few examples, like: paho.mqtt.cpp/examples/async_consume.cpp Lines 72 to 76 in 3631bce
If the server does not have a session present for your client, then you do need to re-subscribe. |
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: