ioredis - Redis connectTimeout is set, but client is still alive - Stack Overflow

I'm using ioredis to connect to Redis in my project. I discovered that some of the clients are not

I'm using ioredis to connect to Redis in my project. I discovered that some of the clients are not closing for too long time, so I've added connectTimeout and connectionName attributes for each Redis client to identify them. Here is how I connect to Redis:

const redis = new Redis({
  host: process.env.REDIS_HOST,
  port: process.env.REDIS_PORT,
  password: process.env.REDIS_PASSWORD,
  username: process.env.REDIS_USERNAME,
  db: process.env.REDIS_DB,
  connectTimeout: 10000,
  connectionName: connectionName,
});

But still, when I connect via Redis CLI and run CLIENT LIST I can see that some clients have idle time bigger than 10000. So it looks like connectTimeout doesn't work. Any idea why?

Here sample output from CLIENT LIST:

I'm using ioredis to connect to Redis in my project. I discovered that some of the clients are not closing for too long time, so I've added connectTimeout and connectionName attributes for each Redis client to identify them. Here is how I connect to Redis:

const redis = new Redis({
  host: process.env.REDIS_HOST,
  port: process.env.REDIS_PORT,
  password: process.env.REDIS_PASSWORD,
  username: process.env.REDIS_USERNAME,
  db: process.env.REDIS_DB,
  connectTimeout: 10000,
  connectionName: connectionName,
});

But still, when I connect via Redis CLI and run CLIENT LIST I can see that some clients have idle time bigger than 10000. So it looks like connectTimeout doesn't work. Any idea why?

Here sample output from CLIENT LIST:

Share Improve this question asked Mar 24 at 8:14 bobbylejbobbylej 405 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I've had this problem in the past as well. I'm sure there's a setting to fix it but I've always just been lazy and call .quit from my code when I'm done with a connection. This runs the QUIT command on Redis and then Redis shuts down the connection immediately instead of wait for it to be timed out.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744254459a4565327.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信