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

[WIP] fix: Reconnect WebSocket #2054

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

Conversation

Crash--
Copy link
Contributor

@Crash-- Crash-- commented Mar 14, 2023

If an application is opened for a long time, aka in a long life browser's tab and you never close the browser and that the client can go on a sleep or else, WS can not be connected.

So we try 2 things here:

  • First is to reconnect after a refreshedToken. It can be useful because CozyClient will try to refresh the token after 24h. So if the token is refreshed, it means that the client has an internet connexion and just make a request so it's the right time to reconnect with this new token

  • Second is to play with the visibility API. Before, the reconnexion was not very aggressive. We only tried if we were in a process to trying to reconnect by accelerating the reconnexion process. Now we try to reconnect also if the current websocket is closed.

If an application is opened for a long time, aka in a
long life browser's tab and you never close the browser
and that the client can go on a sleep or else, WS can
not be connected.

So we try 2 things here:
- First is to reconnect after a refreshedToken. It can
be useful because CozyClient will try to refresh the token
after 24h. So if the token is refreshed, it means that
the client has an internet connexion and just make a request
so it's the right time to reconnect with this new token

- Second is to play with the visibility API. Before, the
reconnexion was not very aggressive. We only tried if we
were in a process to trying to reconnect by accelerating
the reconnexion process. Now we try to reconnect also if
the current websocket is closed.
@Crash-- Crash-- requested a review from Ldoppea as a code owner March 14, 2023 14:33
@Crash--
Copy link
Contributor Author

Crash-- commented Mar 16, 2023

note rapide :

  • le reconnect se fait bien, seulement, il se peut que le token soit expiré pour le realtime, et dans ce cas, on se prend une erreur de connexion. Il faudrait certainement lancer un refresh token de cozy-client dans ce cas là.
  • Une fois le refreshToken déclenché (en balançant une nouvelle requête cozy-client qui échoue la première fois par token expiré) alors la connexion se fait correctement.

donc à faire: gérer le cas du token expiré lors de la connexion du realtime.

Et est-ce qu'on doit relancer toutes les requêtes en cache de cozy-client aussi histoire de se mettre à jour...

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