Operating System - Linux
1753960 Members
7511 Online
108811 Solutions
New Discussion

Too many CLOSED_WAIT connections

 
Duffster
Valued Contributor

Too many CLOSED_WAIT connections

Hi,

 

I am running JBOSS 6 ona RHEL5 server put it continuously crashes due to the number of CLOSE_WAIT connections on port 8080.

 

How can I kill the several hundred CLOSE_WAIT connections without killing the actual live "LISTENING" connection?

 

R,

D.

1 REPLY 1
Matti_Kurkela
Honored Contributor

Re: Too many CLOSED_WAIT connections

Get your application fixed.(There used to be some JVM bugs in Java 1.4.x.x related to this, but I think they have been fixed a long time ago.)

 

CLOSE_WAIT means the remote side has reported it's closing the remote->local side of the connection (i.e. the remote won't send any more data) but the local application has not told the OS to close the local->remote side. This is called a "half-closed" TCP connection and it's the only way to implement a one-way TCP connection, should you need one.

 

The application can legitimately keep a socket in CLOSE_WAIT as long as it wants, to allow it to complete whatever data transmission it has to do. So there are no OS-level timers that would force the connection to close.

 

Forcing the connections to close by sysadmin command would be about the networking equivalent of truncating some files the application has open for writing: although the results probably won't be as dire, you should understand this is not something you should be doing.

 

If your application uses the HttpURLConnection class, explicitly calling its disconnect() method would be a good thing.

If you're using the URLConnection.getInputStream() or getOutputStream(), use the close() method of the stream. If your application uses the Socket class, then remember to close() the socket.

MK