Multiple complete HTTP requests stuck in TCP CLOSE_WAIT state
        Posted  
        
            by 
                Sean Owen
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Sean Owen
        
        
        
        Published on 2009-09-08T14:14:32Z
        Indexed on 
            2011/11/28
            17:55 UTC
        
        
        Read the original article
        Hit count: 422
        
I have a Java and Tomcat-based server application which initiates many outbound HTTP requests to other web sites. We use Jakarta's HTTP Core/Client libraries, very latest versions.
The server locks up at some point since all its worker threads are stuck trying to close completed HTTP connections. Using 'lsof' reveals a bunch of sockets stuck in TCP CLOSE_WAIT state.
This doesn't happen for all, or even most connections. In fact, I saw it before and resolved it by making sure to set the Connection: Close response header. So that makes me think it may be bad behavior of remote servers.
It may have come up again since I moved the app to a totally new service provider -- different OS, network situation.
But, I am still at a loss as to what I could do, if anything, to work around this. Some poking around on the internet didn't turn up anything I'm not already doing. Just thought I'd ask if anyone has seen and solved this?
© Stack Overflow or respective owner