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

Auto reconnect WebSockets on close #3

Open
davidje13 opened this issue Sep 8, 2019 · 1 comment
Open

Auto reconnect WebSockets on close #3

davidje13 opened this issue Sep 8, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@davidje13
Copy link
Owner

Close events are currently detected, but ignored (except for cancelling keepalive pings)

The client should attempt to automatically reconnect if the connection is lost unintentionally. This should use retry logic with an increasing delay to avoid self-DDoS.

If connection is lost for several seconds without reconnecting, a non-intrusive message should be displayed to the user.

@davidje13
Copy link
Owner Author

To prevent missed or duplicated messages after reconnection, the server will need to keep track of which messages it has already handled;

  • on first connection, a client should request a UUID from the server
  • server should generate and return this UUID
  • client stores UUID locally (in-memory or in session storage)
  • messages sent by client include incrementing ID (already the case? I think this is used for matching the reflected messages)
  • server keeps track of highest ID handled for each client connection (stored as part of the main data, as a map of UUID -> counter, but not sent to any clients), and ignores any messages with ID lower than the current recorded value for that client UUID
  • on reconnection, client sends stored UUID instead of requesting new UUID
  • server associates new connection with the same UUID

Client UUIDs are known only to the server and the client, not other clients. It may also be necessary to limit the maximum number of UUIDs tracked by the server (perhaps including a timestamp in each entry and removing the oldest to maintain a maximum count, or more simply by keeping an ordered list in most-recently-used order)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant