mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Move/refactor keepalive logic and add disconnect timer
We now disconnect ourselves if we don't get the server's response to a
keepalive request within 30s. This way we will eventually disconnect if
the network goes away but the socket is not closed.*
* See code.google.com/p/chromium/issues/detail?id=197841 and
https://stackoverflow.com/questions/11755605/chrome-websocket-connection-not-closed-when-browser-closed
We will then try to reconnect once a minute (See 8a10c96);
Keepalives belong at this level anyway, since the format is defined by
both the websocket resource protocol and our specific server url
structure.
// FREEBIE
This commit is contained in:
@@ -75,20 +75,4 @@ describe('TextSecureWebSocket', function() {
|
||||
mockServer.close();
|
||||
});
|
||||
|
||||
it('sends a keepalive once a minute', function(done) {
|
||||
this.timeout(60000);
|
||||
var mockServer = new MockServer('ws://localhost:8081');
|
||||
mockServer.on('connection', function(server) {
|
||||
server.on('message', function(data) {
|
||||
var message = textsecure.protobuf.WebSocketMessage.decode(data);
|
||||
assert.strictEqual(message.type, textsecure.protobuf.WebSocketMessage.Type.REQUEST);
|
||||
assert.strictEqual(message.request.verb, 'GET');
|
||||
assert.strictEqual(message.request.path, '/v1/keepalive');
|
||||
socket.close();
|
||||
server.close();
|
||||
done();
|
||||
});
|
||||
});
|
||||
var socket = new TextSecureWebSocket('ws://localhost:8081');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user