[erlang-questions] Difference in 'close' for gen_tcp recv vs. active
Dror Mein
drormein@REDACTED
Wed Apr 16 18:09:51 CEST 2014
thank you! it works
On Sunday, April 13, 2014 11:20 PM, Jacob <jacob01@REDACTED> wrote:
Hi
On 13.04.2014 17:35, Dror Mein wrote:
> I had the same problem, but I thought using {keepalive,true} or
> {send_timeout,Time} would help. I see in wireshark that keep alive does
> not pass through but I still don't get an {error, closed}.
> Someone wrote that default timeout for keepalive is two hours. where can
> it be configured?
TCP keepalive configuration is OS dependant. What OS are you using?
NOTE: The following applies to _Linux_ :
With Linux you can either set it
a) globally via sysctl net.ipv4.tcp_keepalive_*
b) globally per /proc/sys/net/ipv4/tcp_keepalive_*
c) per socket with setsockopt() and TCP_KEEPCNT, TCP_KEEPIDLE,
TCP_KEEPINTVL
d) per started (ELF) executable with the libkeepalive wrapper (see below).
see tcp(7) for details.
A helpful HOWTO can be found here:
http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/
ad d):
See the HOWTO above for details. I installed the libkeepalive0 package
(Ubuntu 13.10), tried it with Erlang (erts-6.0) and according to strace
it seems to work. I would avoid LD_PRELOAD hacks in production though.
The command line was
LD_PRELOAD=libkeepalive.so KEEPCNT=20 KEEPIDLE=180 KEEPINTVL=60 erl
If you want to use strace to check what happens enter:
LD_PRELOAD=libkeepalive.so KEEPCNT=20 KEEPIDLE=180 KEEPINTVL=60 strace
-f -o keep.str -e trace=setsockopt erl
and look into keep.str after using gen_tcp:connect/3.
HTH,
Jacob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140416/d607e65b/attachment.htm>
More information about the erlang-questions
mailing list