Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


On reconnect loses reference to net socket #51

nickpoorman opened this Issue · 0 comments

1 participant


After a reconnect() seaport loses the reference to the net socket, which makes it impossible to do a close().

I think what you want below on line 46 is:

c =, hubs[conIx].port, hubs[conIx].host);


var c =, hubs[conIx].port, hubs[conIx].host);

    var c = (function reconnect () {
        if (s.closed) return;

        var hubs = [ { port : port, host : host } ].concat(s.query('seaport'));
        if (hubs.length <= conIx) conIx = hubs.length - 1;
 ==>    c =, hubs[conIx].port, hubs[conIx].host);
        conIx = (conIx + 1) % hubs.length;

        var active = true;

        c.on('connect', s.emit.bind(s, 'connect'));

        c.on('end', onend);
        c.on('error', onend);
        c.on('close', onend);

        var stream = s.createStream();


        stream.on('synced', s.emit.bind(s, 'synced'));

        return c;

        function onend () {
            if (s.closed) return;
            if (!active) return;
            active = false;
            setTimeout(reconnect, 1000);

    s.on('close', function () {
        if (c) c.end();

    return s;
@nickpoorman nickpoorman referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@nickpoorman nickpoorman referenced this issue from a commit in nickpoorman/seaport
@nickpoorman nickpoorman fixes #51 ed35b15
@nickpoorman nickpoorman referenced this issue

fixes #51 #52

@substack substack closed this issue from a commit
@nickpoorman nickpoorman fixes #51 32ffdda
@substack substack closed this in 32ffdda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.