Enable TCP Keep-Alive on WebSockets
This commit is contained in:
parent
7a512dfbed
commit
47c0cc053a
1 changed files with 3 additions and 0 deletions
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue