Edit /etc/sysctl.conf file.
Add or modify line with parameter net.ipv4.tcp_keepalive_time and set keepalive time to be 10 minutes so it looks like
net.ipv4.tcp_keepalive_time=600
Here is example how to check, modify settings and then apply it
user@host /path % sudo cat /proc/sys/net/ipv4/tcp_keepalive_time # check current settings