-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add Reconnection Logic to Websocket #2728
Comments
hey @Alek99 , dyu mean Once the tab is visible ie the user clicks on the tab ? and by tab , you mean browser tab? |
Correct on both, when the user clicks on the tab and browser tab |
apart from the obvious impl you stated above and incorprating it in const connect in state.js , is there any thing else to account for ? I wanna work on this |
That pretty much it, just needs to reconnect if the tab is old an/or socket connection is lost. I don't want to rush you on this ticket we really appreciate you wanting to contribute, but this issue is on the higher priority side for us so ideally looking to get this in for the next release if possible. I can suggest other issues if this timeline doesn't work for you, no worries. |
when is the next release? |
Cut off for 0.4.3 is Thursday Feb 29; Release on March 4 If it's after the 29th, then it will go into the next release on March 11 |
After a while the socket loses connection with the tab, that's what I meant by old tab |
ohk, i'd raise the PR tmr, thanks.
you mean if the user spends a long time outside the "reflex tab" , the connection closes and doesn't reconnect, correct ? |
Thanks! Yeah that's correct |
Right now there is no reconnecting logic for the websocket. After some investigation, I think we can use the visibilitychange event to re-establish a connection if there isn't one already.
One the tab is visible ie the use clicks on the tab for the reflex app we would do some check and re establish the connection.
Some short example code of how its done in another context:
For those interested in tackling this ticket we probably need to edit https://github.com/reflex-dev/reflex/blob/main/reflex/.templates/web/utils/state.js to incorporate this logic.
The text was updated successfully, but these errors were encountered: