Skip to content
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

Subscriptions are not renewed when auto-reconnecting #221

Closed
SeadexWP opened this issue Feb 1, 2017 · 4 comments
Closed

Subscriptions are not renewed when auto-reconnecting #221

SeadexWP opened this issue Feb 1, 2017 · 4 comments

Comments

@SeadexWP
Copy link

SeadexWP commented Feb 1, 2017

If a connection to a MQTT broker is lost and auto-reconnected, subscriptions to topics are not renewed (not even with cleansession activated).
This is especially bad if the connection was lost due to a broker crash and the broker cannot (or does not want to) restore old sessions.
I was told (I did not confirm this) that the paho Java MQTT client does this correctly.

@ralight
Copy link
Contributor

ralight commented Feb 1, 2017

It was a conscious decision not to do this. It is easy to do at the client level by subscribing in the on_connect() callback.

@SeadexWP
Copy link
Author

SeadexWP commented Feb 2, 2017

It was a conscious decision not to do this.

Thanks for the info!

It is easy to do at the client level by subscribing in the on_connect() callback

I used the on_connect() approach in my thin C++ wrapper.
And I agree that it is not a big effort to do this "manually", however I don't quite see the point to push this task onto the client. It's just plumbing that the client has to take care off: No obvious benefit, or is there something I overlook? I can't quite see the secenario in which - after a (unwanted) disconnect with auto-reconnect - I would not want to subscribe the topics I had subscribed before.
Maybe at least an optional auto-resubscribe can be considered for future versions?!

@icraggs
Copy link
Contributor

icraggs commented Apr 6, 2017

If you want to retain the subscriptions, then you have the option of connecting with cleansession=false.

I do realize that there are drawbacks to this solution, given the semantics of clean session in MQTT (which should be solved in MQTT v5 incidentally).

The Paho Java client has the same behaviour, so I think your information is wrong in that case.

@icraggs
Copy link
Contributor

icraggs commented Apr 21, 2017

I'm going to close this as being the way that the MQTT 3.1.1 clients work. When V5 comes along, the protocol update will fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants