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

Fix reconnect related bugs #112

Merged
merged 2 commits into from
Jan 4, 2024
Merged

Fix reconnect related bugs #112

merged 2 commits into from
Jan 4, 2024

Conversation

achilleasa
Copy link
Owner

This PR fixes two issues in the reconnection-handling logic that were reported in #107:

  1. The client error broadcast stream is now closed only if the client's close() method is explicitly called. This allows existing listeners to be re-used if the client opts to detect connection loss events and reconnect to the broker.

  2. When reconnecting, the previous heartbeat check timer was overwritten without first being cancelled. As a result, the old timer would eventually fire and raise a HeartbeatFailedException which would in turn trigger a new connection attempt to be made.

fixes #107

This change addresses one of the issues described in
#107.

Prior to this change, the error broadcast stream was always closed when
the connection was closed either by the client or the server. This
prevented clients that implemented a reconnection policy from being able
to register error listeners.

This commit modifies the client behavior so that the error broadcast
channel is only closed if the client invokes the close() method on a
client instance.
This commit fixes a bug in the reconnect handling code where the client
would overwrite a pre-existing heartbeat timer without first cancelling
it. As a result, the old timer would eventually fire and trigger a
HeartbeatFailedException closing the connection.
@achilleasa achilleasa merged commit 6cdc538 into master Jan 4, 2024
1 check passed
@achilleasa achilleasa deleted the fix-reconnect-related-bugs branch January 4, 2024 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

errorListener and heartbeat do not work if the connection was closed by server and reestablished again
1 participant