ec2 forced close of idle connections
Wed Jun 24 21:49:42 CEST 2009
There are several reasons this could happen.
TCP connections should stay alive forever unless programmed with an
On the client side however most commercial and residential gateways/
firewalls/modems that use NAT will release the mapping for a NAT'd TCP
connection if it is idle for around 30 seconds, this will usually not
be noticed by the server as the NAT device does not usually send a FIN
etc, but the client will get a RST when it tries to send something on
the lost NAT'd connection.
On the server side many load balancers (and NATing devices) will also
discard the mapping for a TCP connection if it is idle for more than a
certain time, which is usually configurable. There is no way to know
if Amazon has these devices in front of the EC2.
One way to check is open an ssh to the EC2 instance and don't type
anything for 30 seconds and see if it stays open, then try to
determine which end closed first (probably the client side if you are
behind a residential gateway that uses NAT).
For these long-lived TCP connections I usually send a ping type
command every 20 seconds from the client to keep everything open, I
never use the TCP keep-alive as it used to not be well supported, that
may have changed.
On Jun 24, 7:14 am, Joel Reymont <> wrote:
> I'm noticing that my idle TCP connections to a server running on EC2
> (Erlang!) are being closed after just 20-30 seconds.
> Has anyone experienced this?
> Is this a ploy by Amazon to boost network traffic with keep-alives?
> Thanks, Joel
> Mac hacker with a performance benthttp://www.linkedin.com/in/joelreymont
> erlang-questions mailing list. Seehttp://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
More information about the erlang-questions