-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setPingConnectionInterval for node-redis #1598
Comments
Hi team, |
Hi Team, |
Hi @mercury200Hg, we are currently focusing on V4. Also, I think that this problem should be solved using "TCP keepalive" instead of a PING command. I'm adding this issue to the V4 to-do list. |
@leibale TCP keepalive doesn't usually have effect as LoadBalancers don't honour it and closes the connection if idle for more than their fixed time period. This is the case for most of cloud providers. We tried testing with keepalive but after the designated period given by AWS/Azure loadbalancer the client gives error of - timed out. Now this case has to be handled at client side and connection to be re-initiated and it works after that. With something which checks PING at certain frequency the connection never remains idle and the errors in app are reduced. Thanks for adding it in V4 to-do-list. Let me know if i can contribute there. |
@mercury200Hg can you please share a link to the load balancer you're using/trying to use? I want to search for another solution, cause sending a PING command just to keep the connection alive is too much in my opinion, there has to be another "less expensive" solution. Regarding contributing code - feel free to clone the project, checkout to a new branch from the v4 branch, make the changes, and open a PR. BTW, in the meantime, you can use setInterval(client => {
client.ping((err) => {
if (err) console.error('Redis keepalive error', err);
});
}, X); |
Link to load balancer for your info : |
Is this already implemented or there's still scope to add this ? @leibale |
I still don't understand why there's a need to issue a |
That's because for cloud providers like Azure/AWS LoadBalancers don't honor the TCP connection alive set from Redis client. |
Why your redis server is behind a load balancer? |
That's how Azure managed Redis works internally. 😅 |
Issue
Basically, if you run redis behind AWS-NLB or Azure-Loadbalancer there's an idle timeout configured by LoadBalancer like 350 seconds for AWS and 4 minutes for azure. Despite the keepalive you set on the machine hosting redis, the connection from the node app will be dropped if it's idle for more than the above time.
Is it possible to enable a parameter like
setPingConnectionInterval
which basically sends a PING request to redis to keep the connection alive and prevent it from dropping?This could be same as the
setPingConnectionInterval used in Redisson client
orsetTestOnBorrow in jedis
.If there's existing functionality that takes care of it, please help out in pointing the same. Say-
socket_initial_delay
which statesthis will also behave the interval keep-alive message sending to Redis.
From what I understand it will keep on sending the messages to keep the connection alive other than the initial delay. Correct me if i am wrong here.Environment
9.1.0
5.0.6
Ubuntu-18.04
The text was updated successfully, but these errors were encountered: