Skip to content

Commit 6b59a36

Browse files
committed
Only enables keep-alive on lib-created TCP connections.
1 parent 288d997 commit 6b59a36

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/connection.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ class Connection extends EventEmitter {
3636
opts.config.port,
3737
opts.config.host
3838
);
39+
40+
// Enable keep-alive on the socket. It's disabled by default, but the
41+
// user can enable it and supply an initial delay.
42+
this.stream.setKeepAlive(true, this.config.keepAliveInitialDelay);
3943
}
4044
// if stream is a function, treat it as "stream agent / factory"
4145
} else if (typeof opts.config.stream === 'function') {
@@ -44,11 +48,6 @@ class Connection extends EventEmitter {
4448
this.stream = opts.config.stream;
4549
}
4650

47-
// Enable keep-alive on the socket. It's disabled by default, but the
48-
// user can enable it and supply an initial delay.
49-
if (typeof this.stream.setKeepAlive === 'function' && this.config.enableKeepAlive)
50-
this.stream.setKeepAlive(true, this.config.keepAliveInitialDelay);
51-
5251
this._internalId = _connectionId++;
5352
this._commands = new Queue();
5453
this._command = null;

0 commit comments

Comments
 (0)