Skip to content

Commit

Permalink
add option socket_initialdelay
Browse files Browse the repository at this point in the history
  • Loading branch information
betimer committed Nov 29, 2018
1 parent bd66d62 commit 8ee1b98
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Expand Up @@ -101,6 +101,10 @@ function RedisClient (options, stream) {
if (options.socket_keepalive === undefined) {
options.socket_keepalive = true;
}
if (options.socket_initialdelay === undefined) {
options.socket_initialdelay = 0;
// set default to 0, which is aligned to https://nodejs.org/api/net.html#net_socket_setkeepalive_enable_initialdelay
}
for (var command in options.rename_commands) {
options.rename_commands[command.toLowerCase()] = options.rename_commands[command];
}
Expand Down Expand Up @@ -416,7 +420,7 @@ RedisClient.prototype.on_connect = function () {
this.connected = true;
this.ready = false;
this.emitted_end = false;
this.stream.setKeepAlive(this.options.socket_keepalive);
this.stream.setKeepAlive(this.options.socket_keepalive, this.options.socket_initialdelay);
this.stream.setTimeout(0);

this.emit('connect');
Expand Down

3 comments on commit 8ee1b98

@anhzhi
Copy link

@anhzhi anhzhi commented on 8ee1b98 Dec 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
any plan of release?

@betimer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anhzhi I am also waiting for the release, in case you want to have it right now (pointing to: https://github.com/betimer/node_redis) (A bit bad practice though)

@anhzhi
Copy link

@anhzhi anhzhi commented on 8ee1b98 Jan 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@betimer you can set socket_initialdelay in the callback function when socket connected:

client.on('connect', function () {
    var socket = client.stream
    socket.setKeepAlive(true, 30 * 1000)
})

Please sign in to comment.