Where in the configuration file do I set the connection timeout for Redis?
I know there is a timeout setting in the config file, but that only applies for idle connections. I want the timeout to apply when I want to read from redis. I want it to time out only after N seconds, rather than the default.
Redis can handle many connections, and by default, Redis has a maximum number of client connections set at 10,000 connections. You can set the maximum number of client connections you want the Redis server to accept by altering the maxclient from within the redis. conf file.
From version 3.2 onwards, Redis has TCP keepalive ( SO_KEEPALIVE socket option) enabled by default and set to about 300 seconds.
Redis client uses a single TCP connection and can only read one response at a time. Even when a first operation times out, it does not stop the data being sent to/from the server. Because of this, it blocks other requests and causes timeouts.
By default, Redis will never close idle connections, which means that if you don't close your Redis connections explicitly, you will lock yourself out of your instance. To ensure this doesn't happen, Heroku Redis sets a default connection timeout of 300 seconds.
For anyone who is still looking for this, on a redis connnection string you can specify connectTimeout like below.
<add key="RedisConnectionString" value="your-redis-server,abortConnect=false,connectTimeout=1000,ssl=false,,password=your-password" />
On console of redis set this configuration
config set timeout 300
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With