pgriess/node-websocket-client — Issue #23: Proper implementation of an auto-reconnect?
Author: ryonlife
Created: 2011-12-31 20:37:44+00:00
State: open

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);
});

Any insights for me? Thanks.