0

What is best solution to manage connection in NodeJS connected via SockJS (websocket) to be durable(do not disconnect) for some time during user reloads the page?

Can I do that with session?

theZiki
  • 939
  • 1
  • 8
  • 14

1 Answers1

3

SockJS, native websockets and all resources that the browser maintains are released when the user reloads (or leaves) the web page. Cache, localstorage (and friends) and cookies are notable exceptions.

If you wish to have a SockJS connection when a page is open - well, you need to establish a connection when the page is opened.

SockJS is pretty fast and apparently it works fine even if you have loads of short-lived connections.

(BTW, take a look at web workers with websockets)

Marek
  • 3,471
  • 1
  • 16
  • 15
  • I have created working chat application and online users, but every time user reloads page connection get closed what is normal and OK. I just want that time between connection closed and opened again to be opened. – theZiki Sep 17 '12 at 17:39
  • That's a wrong approach. Assume you can have multiple connections per user during a lifetime of a chat session. – Marek Sep 18 '12 at 03:31
  • 1
    Assume you can have multiple connections from a single user. For example - think what will happen if a single user opens more than one browser tab. – Marek Dec 12 '12 at 12:44