mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-02 22:31:31 +01:00
Enable TCP Keep-Alive on WebSockets
This commit is contained in:
@@ -17,6 +17,7 @@ import { ConnectTimeoutError, HTTPError } from './Errors';
|
||||
import { handleStatusCode, translateError } from './Utils';
|
||||
|
||||
const TEN_SECONDS = 10 * durations.SECOND;
|
||||
const KEEPALIVE_INTERVAL_MS = TEN_SECONDS;
|
||||
|
||||
export type IResource = {
|
||||
close(code: number, reason: string): void;
|
||||
@@ -76,6 +77,8 @@ export function connect<Resource extends IResource>({
|
||||
client.on('connect', socket => {
|
||||
Timers.clearTimeout(timer);
|
||||
|
||||
socket.socket.setKeepAlive(true, KEEPALIVE_INTERVAL_MS);
|
||||
|
||||
resource = createResource(socket);
|
||||
resolve(resource);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user