Affected products
- .NET Framework 1.0
- .NET Framework 1.1
Summary
When making several connections concurrently with the HttpWebRequest class, the request objects fail with an exception.
Symptoms
When making several connections concurrently (more than 12 on a single processor machine) with the HttpWebRequest class, the request objects fail with an exception.
If these calls are made from methods running on ThreadPool thhreads, the maximum number of connections is further reduced.
Cause
The HttpWebRequest uses two threads for each connection from the ThreadPool. This pool has a maximal capacity of 25 on one processor machines. Regularly, if the pool is full, it would queue further requests. But the HttpWebRequest class checks whether two threads are available before putting its requests into the queue. It fails with an exception, when there are less than two threads available.
Status
This behaviour is by design.
Solution
Keep concurrent connections as low as possible, and don't initiate requests from methods running on ThreadPool threads.
Other information
To keep the concurrent connections low, you can use the Advanced Threadpool from the Toolbox area of this page. This class implements a thread pool, which is independent of the ThreadPool class. With this class, you can set the maximium number of concurrent threads, so that the limit of the ThreadPool is never reached.
9ee02aa8-66d7-4bac-afc3-e823e37f1e4c|1|5.0