Windows – Connections to IIS sometimes get stuck in CLOSE_WAIT state

asp.netiis-6web serviceswindowswindows-xp

Our application includes an ASP.Net web service that only needs to deal with a handful of clients. As such, the 10 incoming connection limit of Windows XP Pro is generally not a problem. However, on one particular server, connections are occasionally becoming stuck in the CLOSE_WAIT state. These connections build up over time and eventually new client connections are refused because the maximum number of connections are used up.

From my googling it sounds like a failure of the webservice to properly close the connection can cause this problem, but as it works just fine on hundreds of other Windows XP pro machines I can't see it being a bug in our code. It also ran fine on the affected machine until some shenanigans on the part of the end user (I think they set about deleting duplicate files in order to reduce their disk usage, but they did not exactly come clean about it).

What could the user have changed to introduce this problem? Is there any way I can force connections that are in CLOSE_WAIT to time out rather than letting them hang around? I have seen suggestions to reduce TcpTimedWaitDelay, but that only relates to the TIME_WAIT state, and changing it did not have any effect.

Best Answer

An issue like that is usually code related with objects that need to be closed and disposed, but your story suggests that it's not in this case. I would check your connection timeout on the Web Site tab for the website. The default is 120 seconds. If that has been raised then it may keep more connections around than on your other machines.

Also check the IIS logs to see if you have unusual traffic. If you have bots or something else visiting your site more often, you may be reaching the connection limits earlier than in the past.