diff --git a/src/DiscordClient.js b/src/DiscordClient.js index 6c8338b..bcbc7bf 100644 --- a/src/DiscordClient.js +++ b/src/DiscordClient.js @@ -22,6 +22,8 @@ const skipReconnectFor = [ 4004, 4010, 4011, 4012, 4013, 4014 ]; +const CLOSE_CONNECTION_ON_NO_ACK = false; + class DiscordClient extends EventEmitter { constructor(token, { intents, gatewayUrl="wss://gateway.discord.gg/?v=9&encoding=json&compress=zlib-stream", apiBase="https://discord.com/api/v9" } = {}) { super(); @@ -48,7 +50,7 @@ class DiscordClient extends EventEmitter { } this._heartbeatInterval = setInterval(() => { - if (!this.gotServerHeartbeatACK) { + if (CLOSE_CONNECTION_ON_NO_ACK && !this.gotServerHeartbeatACK) { logError("Closing due to no heartbeat ACK..."); this.ws.close(1000, "No heartbeat ACK."); return; @@ -224,6 +226,7 @@ class DiscordClient extends EventEmitter { if (this.ws) { log("a websocket connection already exists, killing..."); this.ws.removeAllListeners(); + this._setHeartbeat(-1); this.ws.close(); this.ws = null; }