Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#403 Provide SockJS config for minimum transport fallback timeout #413

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
617 changes: 318 additions & 299 deletions dist/sockjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sockjs.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/sockjs.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sockjs.min.js.map

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions 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 @@ -208,8 +209,10 @@ SockJS.prototype._connect = function() {
}
}

// calculate timeout based on RTO and round trips. Default to 5s
var timeoutMs = (this._rto * Transport.roundTrips) || 5000;
// calculate timeout based on RTO and round trips. Default to 5s. Min timeout is null, can be overridden
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
2 changes: 1 addition & 1 deletion lib/version.js
@@ -1 +1 @@
module.exports = '1.1.4';
module.exports = '1.1.5';
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "sockjs-client",
"description": "SockJS-client is a browser JavaScript library that provides a WebSocket-like object.",
"version": "1.1.4",
"version": "1.1.5",
"author": "Bryce Kahle",
"jsdelivr": "dist/sockjs.min.js",
"browser": {
Expand Down