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).