Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
when will redis server clean invalid client? #1810
Redis has a configuration option for "max client idle time" and by default, the timeout is unlimited.
Since your client didn't disconnect (you vanished the network entirely), you your dead client will either never go away or only go away after the very long TCP timeout of 2 hours.
# Close the connection after a client is idle for N seconds (0 to disable) timeout 0
Redis also has an option to enable keepalives so Redis can actively detect invalid clients that didn't disconnect properly:
# TCP keepalive. # # If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence # of communication. This is useful for two reasons: # # 1) Detect dead peers. # 2) Take the connection alive from the point of view of network # equipment in the middle. # # On Linux, the specified value (in seconds) is the period used to send ACKs. # Note that to close the connection the double of the time is needed. # On other kernels the period depends on the kernel configuration. # # A reasonable value for this option is 60 seconds. tcp-keepalive 0