SockJS close event - reason

197 views
Skip to first unread message

Gilad Artzi

unread,
Apr 2, 2015, 11:25:44 AM4/2/15
to soc...@googlegroups.com
Hello,

I have a question about SockJS close event - could I possibly know the close reason?
In the client side, I get an object as an argument to the onclose callback function - is there anything like that on the node side?

I am giving my clients a time frame in which I save their session data, and I need this time frame to be dynamic - If the client was disconnected due to a ping timeout, their "grace period" should be longer, etc

BTW, I really like the SockJS project, the xhr_streaming transport emulates WebSocket in the best way I have found! :-)

Thanks very much,
Gilad

Chris-S

unread,
Jun 23, 2015, 9:59:17 PM6/23/15
to soc...@googlegroups.com
The general rule of thumb is to create your own ping code - This handles all sorts of possible socket problems, such as zombie sessions.
I get the client to send a ping every 20 seconds, and node to check the array of client ping times every 35 seconds, if the age is over a certain time, the connection is terminated.
Additionally I employ a synchronous ajax request on the browser close event, to send a PHP instant goodbye event back to node.
This works on refresh and on closure of tabs. (stackoverflow has info on it somewhere, else i'll be happy to post the code)

-Chris
Reply all
Reply to author
Forward
0 new messages