Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Proper implementation of an auto-reconnect? #23

Open
ryonlife opened this issue Dec 31, 2011 · 0 comments
Open

Proper implementation of an auto-reconnect? #23

ryonlife opened this issue Dec 31, 2011 · 0 comments

Comments

@ryonlife
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant