diff --git a/js/libtextsecure.js b/js/libtextsecure.js
index aee402d6ff..2ad92fb241 100644
--- a/js/libtextsecure.js
+++ b/js/libtextsecure.js
@@ -38629,8 +38629,13 @@ TextSecureWebSocket = function (url, opts) {
* along with this program. If not, see .
*/
-function KeepAlive(websocketResource) {
+function KeepAlive(websocketResource, opts) {
if (websocketResource instanceof WebSocketResource) {
+ opts = opts || {};
+ this.disconnect = opts.disconnect;
+ if (this.disconnect === undefined) {
+ this.disconnect = true;
+ }
this.wsr = websocketResource;
this.reset();
} else {
@@ -38644,14 +38649,19 @@ KeepAlive.prototype = {
clearTimeout(this.keepAliveTimer);
clearTimeout(this.disconnectTimer);
this.keepAliveTimer = setTimeout(function() {
- this.disconnectTimer = setTimeout(function() {
- this.wsr.close(3001, 'No response to keepalive request');
- }.bind(this), 5000);
this.wsr.sendRequest({
verb: 'GET',
path: '/v1/keepalive',
success: this.reset.bind(this)
});
+ if (this.disconnect) {
+ // automatically disconnect if server doesn't ack
+ this.disconnectTimer = setTimeout(function() {
+ this.wsr.close(3001, 'No response to keepalive request');
+ }.bind(this), 1000);
+ } else {
+ this.reset();
+ }
}.bind(this), 55000);
},
};
@@ -39402,7 +39412,7 @@ TextSecureServer = function () {
console.log('Unknown websocket message', request.path);
}
});
- new KeepAlive(wsr);
+ new KeepAlive(wsr, { disconnect: false });
});
}).then(function() {
return generateKeys(100, progressCallback);
diff --git a/libtextsecure/account_manager.js b/libtextsecure/account_manager.js
index b6bea115a4..066be03a7f 100644
--- a/libtextsecure/account_manager.js
+++ b/libtextsecure/account_manager.js
@@ -73,7 +73,7 @@
console.log('Unknown websocket message', request.path);
}
});
- new KeepAlive(wsr);
+ new KeepAlive(wsr, { disconnect: false });
});
}).then(function() {
return generateKeys(100, progressCallback);
diff --git a/libtextsecure/keepalive.js b/libtextsecure/keepalive.js
index 039374c684..ba50fca2a7 100644
--- a/libtextsecure/keepalive.js
+++ b/libtextsecure/keepalive.js
@@ -14,8 +14,13 @@
* along with this program. If not, see .
*/
-function KeepAlive(websocketResource) {
+function KeepAlive(websocketResource, opts) {
if (websocketResource instanceof WebSocketResource) {
+ opts = opts || {};
+ this.disconnect = opts.disconnect;
+ if (this.disconnect === undefined) {
+ this.disconnect = true;
+ }
this.wsr = websocketResource;
this.reset();
} else {
@@ -29,14 +34,19 @@ KeepAlive.prototype = {
clearTimeout(this.keepAliveTimer);
clearTimeout(this.disconnectTimer);
this.keepAliveTimer = setTimeout(function() {
- this.disconnectTimer = setTimeout(function() {
- this.wsr.close(3001, 'No response to keepalive request');
- }.bind(this), 5000);
this.wsr.sendRequest({
verb: 'GET',
path: '/v1/keepalive',
success: this.reset.bind(this)
});
+ if (this.disconnect) {
+ // automatically disconnect if server doesn't ack
+ this.disconnectTimer = setTimeout(function() {
+ this.wsr.close(3001, 'No response to keepalive request');
+ }.bind(this), 1000);
+ } else {
+ this.reset();
+ }
}.bind(this), 55000);
},
};