keepalive timer?

Matthias Lang matthias@REDACTED
Mon Jun 21 17:39:52 CEST 2004


Your question isn't really about Erlang, it's about sockets.

Erlang's keepalive corresponds to the POSIX* option
SO_KEEPALIVE. Under linux you can query and modify the time through
the /proc interface. E.g. on my desktop:

  for i in /proc/sys/net/ipv4/tcp_keepalive_*; do echo $i; cat $i; done
  /proc/sys/net/ipv4/tcp_keepalive_intvl
  75
  /proc/sys/net/ipv4/tcp_keepalive_probes
  9
  /proc/sys/net/ipv4/tcp_keepalive_time
  7200

The linux source documents this reasonably well, in Documentation/fs/proc.txt

    |tcp_keepalive_probes
    |--------------------
    |
    | Number of  keep  alive  probes  TCP  sends  out,  until  it  
    | decides  that the connection is broken.
    |
    |tcp_keepalive_time
    |------------------
    |
    | How often  TCP  sends out keep alive messages, when keep 
    | alive is enabled. The default is 2 hours.

Google will tell you what the third value does.

It appears that you can't configure the keepalive time on a per-socket
basis, at least not under linux 2.4.25. Maybe it's possible under
other operating systems, probably not. I don't know enough about other
OSs' TCP stacks to answer.

The send_timeout option has been discussed on the mailing list
before. It isn't really related to your question. It doesn't do
exactly what it should, which is probably why it's undocumented. See
also: 

 http://www.erlang.org/ml-archive/erlang-questions/200402/msg00259.html
 http://www.erlang.org/ml-archive/erlang-questions/200302/msg00157.html
 http://www.erlang.org/ml-archive/erlang-questions/200209/msg00076.html
 http://www.erlang.org/ml-archive/erlang-questions/200211/msg00197.html

Matthias

Peter Lund writes:
 > Reading the documentation for module inet:
 > 
 > {keepalive, Boolean}
 >     (TCP/IP sockets) Enables periodic transmission on a connected
 >     socket, when no other data is being exchanged. If the other
 >     end does not respond, the connection is considered broken and
 >     an error message will be sent to the controlling process.
 >     Default disabled.
 > 
 > My question is: How long is this period by default between checks
 > that the TCP connection still is alive?
 > 
 > Is there a way to modify the default? (I saw some traces after some
 > other undocumented option 'send_timeout', but I do not know if that
 > was relevant to this problem or not.)
 > 
 > -- 
 > Peter Lund
 > mobile: +46 70 543 9416
 > http://www.lundata.se



More information about the erlang-questions mailing list