I want to set tcp keep alive on my linux machine. So what I am doing is running a script
if [ `/sbin/sysctl -n net.ipv4.tcp_keepalive_time` != 200 ] ; then
/sbin/sysctl -w net.ipv4.tcp_keepalive_time=200;
But I still have issues with connections to amazon's redshift. Can someone please help and show me how I can check if tcp keep alive is actually set or not?
To check if keep alive is active open a connection, don't exchange any data and verify with tcpdump or similar that packets gets regularly exchanged on the connection, even if no real data get exchanged.
But maybe you just confuse keep-alive with timeout:
- Keep alive: detect if the connection is still active, e.g. that data could be exchanged if necessary. This will detect loss of network connectivity etc. Keep alive is done on the TCP layer.
- Timeout: connections gets closed after some inactivity. This is done at the application layer.
In both cases you will not detect the problem until you try to read or write on the socket.