Reconnecting WebSocket for node.js and the browser