Our java application fetches pages from various websites. One of our customers is finding that their machines have a very large number of TCP/IP connections in CLOSED_WAIT states that are remaining for long periods of time. We have not been able to reproduce this -- any thoughts?
I have attached our basic processing code (with non-relevant code removed). We are running on Microsoft Windows Server 2003 and using Java 6 and the java.net.HttpURLConnection class. For each connection, we close the input stream after reading it, but do not disconnect, so that Java can re-use the connection. This normally produces many connections with TIMED_WAIT states, but only an occasional short-lived CLOSED_WAIT state.