Skip to content

Commit

Permalink
fix: keep alive应当失败三次以上才重新连接
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Apr 2, 2024
1 parent f005860 commit 4e0147a
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,19 +536,16 @@ export class Cluster {
this.keepAliveError = 0
} catch (e) {
this.keepAliveError++
console.error('keep alive error')
console.error(e)
if (this.keepAliveError >= 5) {
console.error('exit')
} else {
logger.error('keep alive error')
if (this.keepAliveError >= 3) {
await Bluebird.try(async () => {
await this.disable()
await this.connect()
await this.enable()
})
.timeout(ms('10m'), 'restart timeout')
.catch((e) => {
console.error(e, 'restart failed')
logger.error(e, 'restart failed')
this.exit(1)
})
}
Expand Down

0 comments on commit 4e0147a

Please sign in to comment.