From 13d0517b5507fc2a6ba997f692c0f8c859bf3c0d Mon Sep 17 00:00:00 2001 From: bangbang93 Date: Mon, 22 Nov 2021 10:42:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3ws=E6=96=AD=E5=BC=80=E4=BD=86?= =?UTF-8?q?=E6=98=AF=E9=87=8D=E6=96=B0=E8=BF=9E=E6=8E=A5=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E6=97=B6=E6=97=A0=E6=B3=95=E6=AD=A3=E7=A1=AEkeep=20alive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cluster.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cluster.ts b/src/cluster.ts index 9b82f7c..c3b33ef 100644 --- a/src/cluster.ts +++ b/src/cluster.ts @@ -227,7 +227,6 @@ export class Cluster { this.io.on('disconnect', (reason: string) => { console.log(`disconnected: ${reason}`) this.isEnabled = false - clearTimeout(this.keepAliveInterval) }) this.io.on('error', this.onConnectionError) this.io.on('connect_error', this.onConnectionError) @@ -269,6 +268,9 @@ export class Cluster { } public async keepAlive(): Promise { + if (!this.isEnabled) { + throw new Error('节点未启用') + } return new Promise((resolve, reject) => { const counters = clone(this.counters) this.io.emit('keep-alive', {