I\'ve recently set-up a local WebSocket server which works fine, however I\'m having a few troubles understanding how I should handle a sudden loss of connection which neith
The websocket protocol defines control frames for ping and pong. So basically, if the server sends a ping, the browser will answer with a pong, and it should work also the other way around. Probably the WebSocket server you use implements them, and you can define a timeout in which the browser must responds or be considered dead. This should be transparent for your implementation in both browser and server.
You can use them to detect half open connections: http://blog.stephencleary.com/2009/05/detection-of-half-open-dropped.html
Also relevant: WebSockets ping/pong, why not TCP keepalive?