- Notifications
You must be signed in to change notification settings - Fork10.1k
how to stay connected to Socket Server from the Client even on refresh on any browser#5380
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Hello, I've written Sockets.IO Server Code in but I am struggling for the Furthermore,Socket Client Options I tried this as well, but this also not working in my Reactjs App. can anyone help me on this? |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 3 comments 2 replies
-
Hi! The WebSocket connection does not survive the page reload. If you need to track which user is connected, you will need to have some kind of authentication (a cookie, for example). Reference:https://developer.mozilla.org/en-US/docs/Web/API/WebSocket |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hello@darrachequesne -- so I can say that, it's the normal & expected behavior of SocketsIO to get disconnect on the page reload? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Yes, that's right. As far as I know, there are no way to persist the connection across page reloads, even within a SharedWorker, which will be killed once there is no more tab connected to it. References: |
BetaWas this translation helpful?Give feedback.
All reactions
-
but how Cookie or something for some kind of authentication will work?@darrachequesne |
BetaWas this translation helpful?Give feedback.
All reactions
-
You can utilize PWA and service workers if you really need to be connected after refresh. |
BetaWas this translation helpful?Give feedback.