Last week I sent a message to the group asking about a particular high number of FIN_WAIT_2 states in my client netstat output. I had written both an http client application (using LWP::UserAgent) and http server application (using IO::Socket) that were communicating with one another. Just out of interest and for the sake of testing, I've done a number of things which seem to result in fewer FIN_WAIT_2 states:
(1) change the http server application to use HTTP::Daemon and use the $c->force_last_request method. The server is still closing the connection after sending out a little bit of information. (2) include a "Connection: close" header in the client's request. (3) change the sysctl variable net.inet.tcp.always_keepalive to false rather than the default behavior of true. First of all, are any of these changes not advisable? I've also noticed that there seems to be a higher likelihood of hanging in a FIN_WAIT_2 state when the client to server connection is made through a proxy? Is there a general reason this would be the case? Would proxies be attempting to keepalive tcp connections to client/server while the client/server had closed them or attempted to? I'd like to now decrease the amount of time the server side stays in the TIME_WAIT state. I know that the FIN_WAIT_2 is the last normal state for the client side and the TIME_WAIT is the last normal state for the server side and their lifetime exists for a reason. However, are there things I can do to decrease the TIME_WAIT lifetime? Thanks, --Ben _____________________________________________________________
