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

Proper implementation of an auto-reconnect? #23

Description

@ryonlife

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions