Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtcode committed Jul 12, 2017
1 parent df5b03c commit 6b1f009
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions lib/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ var CONNECTED = 'connected';


var CLOSE_NORMAL = 1000;
var CLOSE_BAD_KEY = 4403;
var CLOSE_TIMEOUT = 1011;


Expand Down Expand Up @@ -196,9 +195,11 @@ Stream.prototype.opened = function () {
delete this.retry.timeout;
}

if (!this.subscriptions.empty) {
this.subscribe(this.subscriptions.all.slice());
}
// The resubscribe is broken, so just disable it
// by clearing the previous subscriptions on each reconnect.
// if (!this.subscriptions.empty) {
// this.subscribe(this.subscriptions.all.slice());
// }

this.subscriptions.clear();

Expand All @@ -222,19 +223,15 @@ Stream.prototype.closed = function (code, message) {

assert(this.socket.readyState === WS.CLOSED);

if (code === CLOSE_NORMAL || code === CLOSE_BAD_KEY) {
debug('websocket closed');
debug('websocket closed unexpectedly, retry in %dms', this.retry.delay);

} else {
debug('websocket closed unexpectedly, retry in %dms', this.retry.delay);
if (this.retry.timeout) {
clearTimeout(this.retry.timeout);
delete this.retry.timeout;
}

if (this.retry.timeout) {
clearTimeout(this.retry.timeout);
delete this.retry.timeout;
}
this.retry.timeout = setTimeout(this.open, this.retry.delay);

this.retry.timeout = setTimeout(this.open, this.retry.delay);
}

if (this.idle.timeout) {
clearTimeout(this.idle.timeout);
Expand Down Expand Up @@ -464,6 +461,7 @@ Stream.prototype.error = function (error) {

debug(error.message);
this.emit('error', error);
this.socket.close();

return this;
};
Expand Down

0 comments on commit 6b1f009

Please sign in to comment.