Skip to content

Commit

Permalink
Merge pull request #421 from ably/idle-timer-bug
Browse files Browse the repository at this point in the history
Fix idle timeout bug when timer extended due to +ve timeRemaning
  • Loading branch information
SimonWoolf authored Oct 12, 2017
2 parents 1d645c1 + 00b8a39 commit fa2ad1f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions common/lib/transport/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,18 @@ var Transport = (function() {
this.off();
};

Transport.prototype.onActivity = function(timeout) {
Transport.prototype.onActivity = function() {
if(!this.maxIdleInterval) { return; }

this.lastActivity = this.connectionManager.lastActivity = Utils.now();
this.setIdleTimer(this.maxIdleInterval + 100);
};

Transport.prototype.setIdleTimer = function(timeout) {
var self = this;
if(!this.idleTimer) {
this.idleTimer = setTimeout(function() {
self.onIdleTimerExpire();
}, timeout || this.maxIdleInterval);
}, timeout);
}
};

Expand All @@ -205,7 +208,7 @@ var Transport = (function() {
Logger.logAction(Logger.LOG_ERROR, 'Transport.onIdleTimerExpire()', msg);
this.disconnect(new ErrorInfo(msg, 80003, 408));
} else {
this.onActivity(timeRemaining + 10);
this.setIdleTimer(timeRemaining + 100);
}
};

Expand Down

0 comments on commit fa2ad1f

Please sign in to comment.