WebRequest Connection Limit

This took me a while to track down – I was having a problem where I could have two WebRequets objects open and reading data, but when I’d try to open the third one, it would just time out.

Searching Usenet I found quite a few people with the same problem, but no solutions.  After digging for a little while I found out what was going on.

The short answer is this:

ServicePointManager.DefaultConnectionLimit = 10;

Put that at the start of your app and make the number big enough to handle the number of connections you’ll need.  The default value of 2 seems somewhat restrictive – this number controls the size of the thread pool that processes web requests (among other things). 

 

2 Responses to “WebRequest Connection Limit”

  1. pendle Says:

    thanks, I encountered the same problem and this did solve it.

  2. terkosh Says:

    I found no answer except this in any blogs or forums.
    Finaly the solution for my problem which is the same as the !EIGHT YEARS OLD! problem of Steve. Thank you!

Leave a Reply