Clear subscriptions and pending subscriptions when not resubscribing on auto reconnect #631
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When
resubscribeOnAutoReconnectis set to false, and the app tries to subscribe again (from outside the package) to the same topic(s) after an auto-reconnect, thesubscriptionsandpendingSubscriptionslists are not cleared. As a result,registerSubscription()returns the old, no-longer-active subscription, and a new subscription cannot be created—so the subscribe attempt effectively fails.Root cause
During auto-reconnect, when resubscribe is disabled (
resubscribeOnAutoReconnect=false), the internal subscription state is not reset. A subsequent subscribe call for the same topic ends up reusing a stale/invalid subscription entry.Fix
When
resubscribeOnAutoReconnectis false,subscriptionsandpendingSubscriptionsare cleared during the auto-reconnect flow. This allows new subscriptions to be created successfully after reconnect, even for the same topic(s).Notes
This change only affects the
resubscribeOnAutoReconnect=falsescenario; behavior remains unchanged when the flag istrue.