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:
parent
2b073f3365
commit
0cbad730ce
2 changed files with 18 additions and 14 deletions
|
@ -15919,15 +15919,17 @@ window.axolotl.sessions = {
|
|||
function resetKeepAliveTimer() {
|
||||
clearTimeout(keepAliveTimer);
|
||||
keepAliveTimer = setTimeout(function() {
|
||||
socket.send(
|
||||
new textsecure.protobuf.WebSocketMessage({
|
||||
type: textsecure.protobuf.WebSocketMessage.Type.REQUEST,
|
||||
request: { verb: 'GET', path: '/v1/keepalive' }
|
||||
}).encode().toArrayBuffer()
|
||||
);
|
||||
if (socket.readyState === WebSocket.OPEN) {
|
||||
socket.send(
|
||||
new textsecure.protobuf.WebSocketMessage({
|
||||
type: textsecure.protobuf.WebSocketMessage.Type.REQUEST,
|
||||
request: { verb: 'GET', path: '/v1/keepalive' }
|
||||
}).encode().toArrayBuffer()
|
||||
);
|
||||
}
|
||||
|
||||
resetKeepAliveTimer();
|
||||
}, 60000);
|
||||
}, 55000);
|
||||
};
|
||||
|
||||
function onclose(e) {
|
||||
|
|
|
@ -39,15 +39,17 @@
|
|||
function resetKeepAliveTimer() {
|
||||
clearTimeout(keepAliveTimer);
|
||||
keepAliveTimer = setTimeout(function() {
|
||||
socket.send(
|
||||
new textsecure.protobuf.WebSocketMessage({
|
||||
type: textsecure.protobuf.WebSocketMessage.Type.REQUEST,
|
||||
request: { verb: 'GET', path: '/v1/keepalive' }
|
||||
}).encode().toArrayBuffer()
|
||||
);
|
||||
if (socket.readyState === WebSocket.OPEN) {
|
||||
socket.send(
|
||||
new textsecure.protobuf.WebSocketMessage({
|
||||
type: textsecure.protobuf.WebSocketMessage.Type.REQUEST,
|
||||
request: { verb: 'GET', path: '/v1/keepalive' }
|
||||
}).encode().toArrayBuffer()
|
||||
);
|
||||
}
|
||||
|
||||
resetKeepAliveTimer();
|
||||
}, 60000);
|
||||
}, 55000);
|
||||
};
|
||||
|
||||
function onclose(e) {
|
||||
|
|
Loading…
Reference in a new issue