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--;

View File

@@ -99,10 +99,10 @@ class ShardingManager extends EventEmitter {
/**
* Spawns multiple shards.
* @param {number} [amount=this.totalShards] Number of shards to spawn
* @param {number} [delay=5500] How long to wait in between spawning each shard (in milliseconds)
* @param {number} [delay=7500] How long to wait in between spawning each shard (in milliseconds)
* @returns {Promise<Collection<number, Shard>>}
*/
spawn(amount = this.totalShards, delay = 5500) {
spawn(amount = this.totalShards, delay = 7500) {
if (amount === 'auto') {
return Util.fetchRecommendedShards(this.token).then(count => {
this.totalShards = count;