CLOSE_WAIT sockets burst - perhaps because of iptables settings?

Posted by Fabrizio Giudici on Server Fault See other posts from Server Fault or by Fabrizio Giudici
Published on 2012-09-28T08:27:00Z Indexed on 2012/09/28 9:39 UTC
Read the original article Hit count: 287

Filed under:
|
|

I have an Ubuntu 12.04 server virtual box where basically the installed software and configuration are the default ones, plus the installation of a jetty 6 server which servers a few websites. To keep things simple I didn't install apache httpd and used iptables for exposing jetty (which runs on the 8080 port) to the port 80. These are the results of

/sbin/iptables -t nat -L

Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
REDIRECT   tcp  --  anywhere             localhost            tcp dpt:http redir ports 8080
REDIRECT   tcp  --  anywhere             Ubuntu-1104-natty-64-minimal  tcp dpt:http redir ports 8080

Chain INPUT (policy ACCEPT) 
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
REDIRECT   tcp  --  anywhere             localhost            tcp dpt:http redir ports 8080
REDIRECT   tcp  --  anywhere             Ubuntu-1104-natty-64-minimal  tcp dpt:http redir ports 8080

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         

I must confess I have a shallow comprehension of how iptables works, in particular for the different kind of chains. This thing works, but sometimes I have an explosion of sockets that stay permanently in CLOSE_WAIT state. I know about what this state means, but since I didn't write the code that manages servlets (they are handled by jetty) I can't fix the problem by patching my code. Eventually the amount of CLOSE_WAIT sockets builds up and makes the server not responsive, so I have to restart jetty.

I've looked around for similar problems wth CLOSE_WAIT, and only found cases related to the programmer's code, or problems with Tomcat, not Jetty. I was wondering whether they could be related to a partially broken iptables configuration (the alternative is a bug in Jetty 6, but I first want to exclude other possible causes).

Thanks.

© Server Fault or respective owner

Related posts about ubuntu

Related posts about iptables