# Forcibly closed connection error



## Tristaan (Aug 1, 2003)

Hey, all,

I'm desperate here.

I'm not the developer of the code but the Software Quality Analyst tasked with testing the darned thing.

So, here's our problem.

We have a .NET 2.0 Framework web application running on IIS 6.0. We've tested the HELL out of that application and have cleaned up all the performance bottlenecks in that app.

Now we added another parameter. This web app, for certain types of processes, needs to send requests to another machine running a windows service. This windows service is using and Indy idHTTPServer (Indy version 10, btw) to listen to a particular IP port for these XML requests, process them, and send them back.

When we added this to our load testing, suddenly things started going south. When the web application would attempt to make the connection, for certain levels of load, it would generate the following errors:

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)

We have narrowed the problem down to the windows service application. My load testing has been aimed at that application directly and have noticed that, for some reason, the first several connections that get to the server never respond. I see that an attempt at connecting was made within my testing application but there is no indication that the request was received. It's like the request was completely swallowed up by the ether.

We are currently at a loss as to what to try and where to look next.

Any help or insight would be appreciated.


----------



## Tristaan (Aug 1, 2003)

FYI, we resolved this problem.

Turns out that the Indy component for the webserver has a listening queue. We set up a listening port on a particular TCP/IP port. That port has a listening queue that was defaulted to 15. Essentially, if more than one request gets sent to that listening port at a time, they get queued up to 15 requests. Any request beyond the 16th (1 in the port, 15 in the queue) receive the forcibly closed error described above.

We needed to alter our code to change that default value. The Indy Component has a maximum value of 200 for the listen queue so we set our default to 100 and created a configuration option in the application to allow the end user to vary that value between 15 and 200.


----------

