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

If our pinger fails to receive a response, properly disconnect #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sebirdman
Copy link

fixes #12

@@ -624,6 +624,7 @@ class ClientImplementation {

case MESSAGE_TYPE.PINGRESP:
// We don't care whether the server is still there (yet)
this.sendPinger && this.sendPinger.reset();
Copy link
Owner

Choose a reason for hiding this comment

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

We shouldn't reset the pinger on ping response, because we might not have sent anything recently. Imagine:

keepAlive = 60.
T=0 Client sends ping
T = 40 Client receives ping response (after a long time, but still within keepAlive). Client resets timer, so we'll send our next ping at T=100.
T = 90 Server disconnects client because it hasn't received anything in 60*1.5.

Copy link
Author

Choose a reason for hiding this comment

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

hmm thats a scary length of time to have no response, but if that happens then I'll have to rethink this.

Copy link
Owner

Choose a reason for hiding this comment

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

It is a long time, but not something we can rule out. There's also this from the spec

It is the responsibility of the Client to ensure that the interval between Control Packets being sent does not exceed the Keep Alive value.

Even if the response comes back in 1 second, resetting the timer on receipt will mean the time between PINGREQs would be at least keepAlive+1 seconds, which violates the spec. We'd usually get away with it because of the spec's keepalive + 50% grace, but it's not right.

@hardikmodha
Copy link

Any updates guys?

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.

Connection lost but client returns that it is still connected
3 participants