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

Resubscribe automatically if automatically reconnecting but session expired #297

Closed
SgtSilvio opened this issue Jun 13, 2019 · 6 comments · Fixed by #398
Closed

Resubscribe automatically if automatically reconnecting but session expired #297

SgtSilvio opened this issue Jun 13, 2019 · 6 comments · Fixed by #398
Assignees
Milestone

Comments

@SgtSilvio
Copy link
Member

identified with #293

somewhat related to #288

@SgtSilvio
Copy link
Member Author

@adamcrane please vote on this if you are interested to turn this into a feature request.

@adamcrane
Copy link

Yes we would like to turn this into a feature request

@lemoony
Copy link

lemoony commented Jul 11, 2019

Hi @SgtSilvio , is this ticket about implementing an automatic resubscribe mechanism? The thing about "session expired" confused me a bit.

I think it is a bit weird for the client to only support resubscribptions in combination with the Reactive Api and the retry() operator.

Why would anyone using the reconnect mechanism not also want to resubscribe to previous topics? Would be great if this was made into a feature request.

BTW: Still and nonetheless - best mqtt client library for java out there 👍

@SgtSilvio
Copy link
Member Author

Currently automatic reconnect only makes sense if you have a session with a sufficient session expiry. As long as the MQTT broker has a session you do not need to resubscribe as the subscriptions are still valid. Generally it is recommended to have a persistent session when having a use case for automatic reconnect.

I understand that users expect that automatic reconnect restores the subscriptions in case the session expired, so I added the feature label.

I did not remove the question label yet as it is not sure how the subscriptions should be restored.
Consider the following subscriptions

  • subscribe call 1: "a", "b"
  • subscribe call 2: "c"
  • subscribe call 3: "a"

Should the resubscription also send 3 separate subscribes (most likely in a different order) or a combined subscribe with all topic filters ("a", "b", "c", "a")?

@SgtSilvio
Copy link
Member Author

SgtSilvio commented Apr 6, 2020

I did not remove the question label yet as it is not sure how the subscriptions should be restored.
Consider the following subscriptions

  • subscribe call 1: "a", "b"
  • subscribe call 2: "c"
  • subscribe call 3: "a"

Should the resubscription also send 3 separate subscribes (most likely in a different order) or a combined subscribe with all topic filters ("a", "b", "c", "a")?

The current implementation restores the subscriptions grouped as in its original Subscribe packets. For each duplicate subscription to the same topic filter only the last successful subscription is restored.
The subscriptions are restored with the same subscription options (max QoS, no local, retain handling, retain as published) as the last successful subscription for its topic filter.
The Subscribe packets are also restored with the same subscription identifier, but user properties are currently not (re)stored.

In the above example this would be:

  • restored subscribe packet 1: "b"
  • restored subscribe packet 2: "c"
  • restored subscribe packet 3: "a"

@SgtSilvio
Copy link
Member Author

@adamcrane @lemoony automatic resubscribe was finally released with version 1.2.0

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

Successfully merging a pull request may close this issue.

3 participants