Skip to content

Commit

Permalink
Only enables keep-alive on lib-created TCP connections.
Browse files Browse the repository at this point in the history
  • Loading branch information
benbotto committed Dec 17, 2019
1 parent 288d997 commit 6b59a36
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class Connection extends EventEmitter {
opts.config.port,
opts.config.host
);

// Enable keep-alive on the socket. It's disabled by default, but the
// user can enable it and supply an initial delay.
this.stream.setKeepAlive(true, this.config.keepAliveInitialDelay);
}
// if stream is a function, treat it as "stream agent / factory"
} else if (typeof opts.config.stream === 'function') {
Expand All @@ -44,11 +48,6 @@ class Connection extends EventEmitter {
this.stream = opts.config.stream;
}

// Enable keep-alive on the socket. It's disabled by default, but the
// user can enable it and supply an initial delay.
if (typeof this.stream.setKeepAlive === 'function' && this.config.enableKeepAlive)
this.stream.setKeepAlive(true, this.config.keepAliveInitialDelay);

this._internalId = _connectionId++;
this._commands = new Queue();
this._command = null;
Expand Down

0 comments on commit 6b59a36

Please sign in to comment.