Skip to content

Commit

Permalink
- Fix keep alive reconnect to another server issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cristijora committed Dec 22, 2020
1 parent 3fb4e3f commit f233653
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class EventsSDK {
this._registerExtensionsModule();
this._registerQueueModule();
}

getLastEventTimestamp() {
return this._lastEventTimestamp
}
Expand Down Expand Up @@ -305,12 +305,12 @@ class EventsSDK {
if (this.idleInterval) {
clearInterval((this.idleInterval))
}
this.keepAliveInterval = setInterval(() => {
this.keepAliveInterval = setInterval(async () => {
const now = new Date().getTime()
const delta = this.options.keepAliveTimeout * 2

if (now > this.getLastEventTimestamp() + delta) {
this._connect('next')
await this._connect('next', true)
return
}
if (!this.socket) {
Expand Down

0 comments on commit f233653

Please sign in to comment.