Pratap D
Pratap D

Reputation: 321

Is there any way to close idle redis-client connection?

I am using "RedisClient" as shown below: However, the connection is not getting closed after connectTimeout. Kindly let me know.

RedisClient(host = host,
          port = port,
          password = Some(password),
          connectTimeout = Some(timeout))

netstat -atn doesn't show any reduction in connection. They keep growing.

Upvotes: 3

Views: 10786

Answers (1)

llinvokerl
llinvokerl

Reputation: 1045

The parameter connectTimeout is the timeout for attempting to connect Redis server instead of the close time of idle connections.

Redis is not able to configure timeout for a specified Redis connection.

But if you want to configure timeout for all Redis connections, you can configure it in Redis server ahead of time. Once it's configured, All the client connections will be closed after it is idle for the configured time.

Just run for once:

127.0.0.1:6379> CONFIG SET timeout 10

if the client is idle for more than 10s, the client connection will be closed.

Redis Doc

Upvotes: 6

Related Questions