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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744254459a4565327.html
评论列表(0条)