mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
Reconnect on 1000 if client didn't close
This commit is contained in:
@@ -369,13 +369,13 @@ class WebSocketConnection extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
onClose(event) {
|
onClose(event) {
|
||||||
this.debug(`${this.expectingClose ? 'Server' : 'Client'} closed WebSocket connection: ${event.code}`);
|
this.debug(`${this.expectingClose ? 'Server' : 'Client'} closed WebSocket connection: ${event.code}`);
|
||||||
this.expectingClose = false;
|
|
||||||
this.closeSequence = this.sequence;
|
this.closeSequence = this.sequence;
|
||||||
// Reset the state before trying to fix anything
|
// Reset the state before trying to fix anything
|
||||||
this.emit('close', event);
|
this.emit('close', event);
|
||||||
this.heartbeat(-1);
|
this.heartbeat(-1);
|
||||||
// Should we reconnect?
|
// Should we reconnect?
|
||||||
if (Constants.WSCodes[event.code]) {
|
if (event.code === 1000 ? this.expectingClose : Constants.WSCodes[event.code]) {
|
||||||
|
this.expectingClose = false;
|
||||||
/**
|
/**
|
||||||
* Emitted when the client's WebSocket disconnects and will no longer attempt to reconnect.
|
* Emitted when the client's WebSocket disconnects and will no longer attempt to reconnect.
|
||||||
* @event Client#disconnect
|
* @event Client#disconnect
|
||||||
@@ -386,6 +386,7 @@ class WebSocketConnection extends EventEmitter {
|
|||||||
this.destroy();
|
this.destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.expectingClose = false;
|
||||||
this.reconnect();
|
this.reconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user