admin管理员组文章数量:1401673
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
:
1 Answer
Reset to default 0I'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.
本文标签: ioredisRedis connectTimeout is setbut client is still aliveStack Overflow
版权声明:本文标题:ioredis - Redis connectTimeout is set, but client is still alive - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744254458a2597409.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论