When a web socket is closed, what's the proper implementation (from a client perspective, not a server) for auto-reconnecting? My thought is something like this, but I wondered if it's too naive, and whether there are any pitfalls I should be aware of.
connection.on('close', function() {
reconnect = setInterval(function() {
// Standard stuff for opening a new WebSocketClient connection
clearInterval(reconnect);
}, 1000);
});
When a web socket is closed, what's the proper implementation (from a client perspective, not a server) for auto-reconnecting? My thought is something like this, but I wondered if it's too naive, and whether there are any pitfalls I should be aware of.
Any insights for me? Thanks.