how to stay connected to Socket Server from the Client even on refresh on any browser #5380
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 |
Beta Was this translation helpful? Give feedback.
-
Hello @darrachequesne -- so I can say that, it's the normal & expected behavior of SocketsIO to get disconnect on the page reload? |
Beta Was this translation helpful? Give feedback.
-
You can utilize PWA and service workers if you really need to be connected after refresh. |
Beta Was this translation helpful? Give feedback.
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
Nodejs
+Expressjs
withTypeScript
and the Server code is working perfectly fine.but I am struggling for the
Reactjs
Client Side Web App, where I am not able to stay connected to the Sockets Server even on the page refresh, if I am refreshing the Page, then it's getting disconnected and then connect again, but I can't able to find a way to stay connected to the Sockets Server even on page refresh...Furthermore, Socket Client Options I tried this as well, but this also not working in my Reactjs App.
can anyone help me on this?
Beta Was this translation helpful? Give feedback.
All reactions