sockjs / websocket in Chrome stays open after laptop comes out of long sleep

324 views
Skip to first unread message

alexkh...@cureatr.com

unread,
Apr 25, 2013, 1:50:53 PM4/25/13
to soc...@googlegroups.com
I have an app with a sockjs (websocket) connection running in a browser (Chrome) on my laptop. When I re-open the laptop after a long sleep, the connection still appears to be active (onclose hasn't been called, reconnect hasn't triggered), even though it has been correctly dropped on the server (sockjs-tornado) side a long time ago. Any ideas?

Thanks,
Alex

Serge S. Koval

unread,
Apr 25, 2013, 2:04:45 PM4/25/13
to alexkh...@cureatr.com, sockjs
SockJS will only trigger onclose for websocket connection when browser will it that connection closed. SockJS does not support heartbeats at the moment.

So far, I did not see such behavior with Chrome and SockJS - Chrome always calls onclose after notebook comes back from sleep.

Serge.


--
You received this message because you are subscribed to the Google Groups "sockjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sockjs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

alexkh...@cureatr.com

unread,
Apr 25, 2013, 2:15:55 PM4/25/13
to soc...@googlegroups.com, alexkh...@cureatr.com
Thanks Serge. It appears that this may be somewhat of a known issue: https://code.google.com/p/chromium/issues/detail?id=76358 that is not possible to address without heartbeats.

Until there is good support for heartbeats in sockjs, I will probably just try to detect that the browser has been sleeping and force a reconnect in that case.

Alex

Eric Mill

unread,
Apr 25, 2013, 2:24:04 PM4/25/13
to alexkh...@cureatr.com, SockJS
FWIW, implementing a heartbeat yourself isn't the worst. You have to do a small repeating timeout for each client, and to do it both client- and server-side. JavaScript's setInterval is pretty much all you need.

alexkh...@cureatr.com

unread,
Apr 25, 2013, 5:25:30 PM4/25/13
to soc...@googlegroups.com, alexkh...@cureatr.com
That's what I ended up doing - pushed it live, and it seems to work OK. Thanks for the pointers!
Reply all
Reply to author
Forward
0 new messages