'Stale socket in lsof due to REDIS

I'm having a redis connection established and I've a python script which performs CLUSTER MEET, CLUSTER FORGET, IPTBL ADD and IPTBL DELETE.

When I give CLUSTER FORGET. Before FIN packet reaches the other end, it closes the connection and I'm left with a stale socket.

On going through the redis documentation and other blogs I found tcp-keepalive and even after changing it to 300 and restarting the redisd I still see no effect.

/usr/sbin/lsof | grep 16381
redis-ser 23104 admin   10u     IPv6             397237       0t0        TCP *:16381 (LISTEN)
redis-ser 23104 admin   11u     IPv4             397239       0t0        TCP *:16381 (LISTEN)
redis-ser 23104 admin   12u     IPv4             397251       0t0        TCP a.b.c.d:16381->a.b.c.e:56440 (ESTABLISHED)
redis-ser 23104 admin   13u     IPv4             397253       0t0        TCP a.b.c.d:16381->a.b.c.f:58744 (ESTABLISHED)
redis-ser 23104 admin   14u     IPv4             408062       0t0        TCP a.b.c.d:47230->a.b.c.e:16381 (ESTABLISHED)
redis-ser 23104 admin   15u     IPv4             748468       0t0        TCP a.b.c.d:39754->a.b.c.f:16381 (ESTABLISHED)
redis-ser 23104 admin   16u     IPv4             719475       0t0        TCP a.b.c.d:16381->a.b.c.f:58868 (ESTABLISHED)

I would like to understand how to make tcp-keepalive work ? Am I missing something ?

Any help would be appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source