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

Lost connection detection is sensitive to changes in system time #869

Closed
NoahAndrews opened this issue Mar 18, 2019 · 4 comments · Fixed by #878
Closed

Lost connection detection is sensitive to changes in system time #869

NoahAndrews opened this issue Mar 18, 2019 · 4 comments · Fixed by #878

Comments

@NoahAndrews
Copy link
Contributor

NoahAndrews commented Mar 18, 2019

Because Lost Connection Detection uses the java.util.Timer API instead of the ScheduledThreadPoolExecutor API, it is sensitive to changes in the system time. For example, if you set the system time to a point years in the future, the connectionLostTimerTask will be called constantly, frequently causing disconnects as the clients cannot respond before the task is called again. This is particularly an issue for embedded devices that must have their clock set at runtime.

The best solution would seem to be to use the ScheduledThreadPoolExecutor API. I plan to submit a PR.

To Reproduce

  1. Start a WebSocket server using this library
  2. Set the system time to a few years in the future
@marci4
Copy link
Collaborator

marci4 commented Apr 10, 2019

Hey @NoahAndrews,

how can we solve the problem of the last pong received.

I used System.currentTimeMillis() for detecting a missing response.

See https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/java/org/java_websocket/WebSocketImpl.java#L804

Best regards,
Marcel

@NoahAndrews
Copy link
Contributor Author

@marci4 I just updated PR #878 to fix that.

@marci4 marci4 added this to the Release 1.4.1 milestone Apr 14, 2019
@NoahAndrews
Copy link
Contributor Author

Speaking of lost connection detection, I just made this modification to the wiki: https://github.com/TooTallNate/Java-WebSocket/wiki/Lost-connection-detection/_compare/de53ff89cd759a2517cdb36199ce4daf78dbdbe9...4d3b2372b9907c77a23a93f7cf8f132c0fba0537

Let me know if you don't like anything I changed.

@marci4
Copy link
Collaborator

marci4 commented Apr 18, 2019

Looks good!

@marci4 marci4 added the Bug label Apr 22, 2019
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.

2 participants