Skip to content

Commit

Permalink
fix: Hook up the keepAlive after a successful connect
Browse files Browse the repository at this point in the history
Fixes #1339
  • Loading branch information
marcbachmann committed Mar 30, 2022
1 parent 92e7cd9 commit d63e70b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 0 additions & 4 deletions lib/Redis.ts
Expand Up @@ -213,10 +213,6 @@ class Redis extends Commander {
}

_this.stream = stream;
if (typeof options.keepAlive === "number") {
stream.setKeepAlive(true, options.keepAlive);
}

if (stream.connecting) {
stream.once(CONNECT_EVENT, eventHandler.connectHandler(_this));

Expand Down
4 changes: 4 additions & 0 deletions lib/redis/event_handler.ts
Expand Up @@ -16,6 +16,10 @@ export function connectHandler(self) {

self.resetCommandQueue();

if (typeof self.options.keepAlive === "number") {
self.stream.setKeepAlive(true, self.options.keepAlive);
}

// AUTH command should be processed before any other commands
let flushed = false;
const { connectionEpoch } = self;
Expand Down

0 comments on commit d63e70b

Please sign in to comment.