Skip to content

Conversation

@kn100
Copy link
Contributor

@kn100 kn100 commented Jun 12, 2019

Description of the pull request

This PR resets the reconnectAttempts int to zero when the state machine transitions to disconnected. This means that the reconnect logic will trigger whenever .connect() is called again.

Why is the change necessary?

It's weird that the reconnection logic only works until it's exhausted, and then never again.

@kn100
Copy link
Contributor Author

kn100 commented Jun 12, 2019

Fixes #199

@annzenkina
Copy link
Contributor

does this mean there will not be any reconnect attempts anymore after this fix?

@kn100
Copy link
Contributor Author

kn100 commented Jun 14, 2019

No, this just correctly resets the reconnection counter so that the reconnection logic works again a second time.

Before, if the connection failed and six reconnection attempts were exceeded, and the user then decided to call connect again, it would retry once, and then fail.

Copy link
Contributor

@WillSewell WillSewell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I think this needs a test for the new behaviour.

@WillSewell
Copy link
Contributor

I added a test that fails at

assertEquals(ConnectionState.CONNECTING, connection.getState());

Without the fix in this PR.

Copy link

@damdo damdo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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.

5 participants