Don't send keepalive if socket has closed
Also shorten the timeout to see if it improves websocket connection reliability.
This commit is contained in:
@@ -15919,15 +15919,17 @@ window.axolotl.sessions = {
|
|||||||
function resetKeepAliveTimer() {
|
function resetKeepAliveTimer() {
|
||||||
clearTimeout(keepAliveTimer);
|
clearTimeout(keepAliveTimer);
|
||||||
keepAliveTimer = setTimeout(function() {
|
keepAliveTimer = setTimeout(function() {
|
||||||
|
if (socket.readyState === WebSocket.OPEN) {
|
||||||
socket.send(
|
socket.send(
|
||||||
new textsecure.protobuf.WebSocketMessage({
|
new textsecure.protobuf.WebSocketMessage({
|
||||||
type: textsecure.protobuf.WebSocketMessage.Type.REQUEST,
|
type: textsecure.protobuf.WebSocketMessage.Type.REQUEST,
|
||||||
request: { verb: 'GET', path: '/v1/keepalive' }
|
request: { verb: 'GET', path: '/v1/keepalive' }
|
||||||
}).encode().toArrayBuffer()
|
}).encode().toArrayBuffer()
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
resetKeepAliveTimer();
|
resetKeepAliveTimer();
|
||||||
}, 60000);
|
}, 55000);
|
||||||
};
|
};
|
||||||
|
|
||||||
function onclose(e) {
|
function onclose(e) {
|
||||||
|
@@ -39,15 +39,17 @@
|
|||||||
function resetKeepAliveTimer() {
|
function resetKeepAliveTimer() {
|
||||||
clearTimeout(keepAliveTimer);
|
clearTimeout(keepAliveTimer);
|
||||||
keepAliveTimer = setTimeout(function() {
|
keepAliveTimer = setTimeout(function() {
|
||||||
|
if (socket.readyState === WebSocket.OPEN) {
|
||||||
socket.send(
|
socket.send(
|
||||||
new textsecure.protobuf.WebSocketMessage({
|
new textsecure.protobuf.WebSocketMessage({
|
||||||
type: textsecure.protobuf.WebSocketMessage.Type.REQUEST,
|
type: textsecure.protobuf.WebSocketMessage.Type.REQUEST,
|
||||||
request: { verb: 'GET', path: '/v1/keepalive' }
|
request: { verb: 'GET', path: '/v1/keepalive' }
|
||||||
}).encode().toArrayBuffer()
|
}).encode().toArrayBuffer()
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
resetKeepAliveTimer();
|
resetKeepAliveTimer();
|
||||||
}, 60000);
|
}, 55000);
|
||||||
};
|
};
|
||||||
|
|
||||||
function onclose(e) {
|
function onclose(e) {
|
||||||
|
Reference in New Issue
Block a user