Increase WebSocket backoff time to alleviate reconnect issues

This commit is contained in:
Amish Shah
2017-04-22 21:16:58 +01:00
parent 64b378f7d4
commit eec79b5fd0
2 changed files with 6 additions and 4 deletions

View File

@@ -69,6 +69,8 @@ class WebSocketManager extends EventEmitter {
this.lastHeartbeatAck = true;
this._remainingReset = 0;
this._trace = [];
this.resumeStart = -1;
}
@@ -100,7 +102,7 @@ class WebSocketManager extends EventEmitter {
this._connect(gateway);
this.first = false;
} else {
this.client.setTimeout(() => this._connect(gateway), 5500);
this.client.setTimeout(() => this._connect(gateway), 7500);
}
}
@@ -151,7 +153,7 @@ class WebSocketManager extends EventEmitter {
const item = this._queue[0];
if (!(this.ws.readyState === WebSocketConnection.WebSocket.OPEN && item)) return;
if (this.remaining === 0) {
this.client.setTimeout(this.doQueue.bind(this), Date.now() - this.remainingReset);
this.client.setTimeout(this.doQueue.bind(this), Date.now() + (this._remainingReset || 120e3));
return;
}
this._remaining--;