#1615·ioredis

关于 Redis 长链接的问题

作者: ZhangDianPeng创建于 2022年6月29日更新于 2026年9月29日
标签questionstale

We encountered a problem during the use of ioredis. The Redis service connected by nginx is a proxy for master-slave switching through four-layer load balancing. If redis1 can be connected, it will be connected directly to redis1, otherwise it will switch to redis2. However, the node client always connects to nginx:6379. Now we have a problem, that is, when redis1 is down (for example, the power is turned off directly), the node client will wait for about 10 minutes to successfully connect. In the meantime, there is no response. We tested this with the tcp.keepalive configuration of the client itself: