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

feat(sync): Reconnect the websocket on failures. #2235

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

almet
Copy link
Member

@almet almet commented Oct 24, 2024

image

(I didn't manage to capture it, but you can see when the next try will happen on hover)

When the websocket is disconnected, try to redo an authentication roundtrip. This commit does the following changes:

  • Change the way the SyncEngine is instanciated, passing it a server object and the URLs.
  • Add a ping/pong mechanism. This is required because otherwise we have no certainty that the connection is still alive.
  • Offer a "reconnect" mechanism, increasing the wait time a bit more each time.
  • Trigger the reconnect on disconnections and on failure to connect to the websocket (after a specified time)
  • When disconnected the "number of connected peers" now indicates "Disconnected".
  • Display a dialog to the users saying that they are disconnected.

Todo:

  • When offline: let the number of connected peers and add disconnected.
  • Changer la couleur de la fenêtre
  • When offline: change the background color (not red, but something else)
  • Here be dragons. This map has enabled real-time synchronization with other users, but you are currently disconnected. We will try to reconnect in the background and reconcile with other users, but this feature is still experimental, and you might lose data. Have fun!

@almet
Copy link
Member Author

almet commented Oct 25, 2024

I've just added a screen that warns the user when it's disconnected. It looks like this:

image

The template is currently defined in the umap.js file, but maybe it should live in the sync folder instead? I'm curious about where you think this should be?

@almet almet force-pushed the websocket-reconnect branch 2 times, most recently from 548b9eb to 4f575f2 Compare October 25, 2024 13:38
When the websocket is disconnected, try to redo an authentication
roundtrip. This commit does the following changes:

- Change the way the SyncEngine is instanciated, passing it a server
  object and the urls.
- Add a ping/pong mechanism. This is required because otherwise we have
  no certainty that the connection is still alive.
- Try to reconnect when the connection didn't work out, increasing the
  wait time a bit more each time.
Because the WebSockets do not offer a way to know when they failed to
connect, use a delay and check the state of the connection.
@almet almet changed the title feat: Reconnect the websocket on failures. feat(sync): Reconnect the websocket on failures. Oct 25, 2024
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.

1 participant