Skip to content

Commit

Permalink
sockjs#403 Provide SockJS config for minimum transport fallback timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
lennertr committed Oct 29, 2018
1 parent cc6ae95 commit 473b6cd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/main.js
Expand Up @@ -49,6 +49,7 @@ function SockJS(url, protocols, options) {
}
this._transportsWhitelist = options.transports;
this._transportOptions = options.transportOptions || {};
this._transportMinTimeout = options.transportMinTimeout || null;

var sessionId = options.sessionId || 8;
if (typeof sessionId === 'function') {
Expand Down Expand Up @@ -209,7 +210,7 @@ SockJS.prototype._connect = function() {
}

// calculate timeout based on RTO and round trips. Default to 5s
var timeoutMs = (this._rto * Transport.roundTrips) || 5000;
var timeoutMs = ((this._rto > this._transportMinTimeout ? this._rto : this._transportMinTimeout) * Transport.roundTrips) || 5000;
this._transportTimeoutId = setTimeout(this._transportTimeout.bind(this), timeoutMs);
debug('using timeout', timeoutMs);

Expand Down

0 comments on commit 473b6cd

Please sign in to comment.