Skip to content

Commit

Permalink
修正ws断开但是重新连接成功时无法正确keep alive
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Nov 22, 2021
1 parent 0325826 commit 13d0517
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -269,6 +268,9 @@ export class Cluster {
}

public async keepAlive(): Promise<boolean> {
if (!this.isEnabled) {
throw new Error('节点未启用')
}
return new Promise((resolve, reject) => {
const counters = clone(this.counters)
this.io.emit('keep-alive', {
Expand Down

0 comments on commit 13d0517

Please sign in to comment.