"Changing the DefaultConnectionLimit property has no effect on existing
ServicePoint objects; it affects only ServicePoint objects that are
initialized after the change. If the value of this property has not been
set either directly or through configuration, the value defaults to the
constant DefaultPersistentConnectionLimit."

I'd like best to configure the limit when I instanciate the WebClient, but just removing this sad limitation programmatically at the start of my programm would be fine, too.

The server I access is not a regular webserver in the internet, but under my control and in the local lan. I want to do API-calls, but I don't use webservices or remoting

I might upvote this question if I knew why you need to violate international standards.
–
John SaundersMay 14 '09 at 23:32

14

It's not really a standard. The RFC "recommends" that you limit clients to two connections, but it's not really a requirement. More than likely, the poster needs to download more than 2 items at one time.
–
Erik FunkenbuschMay 15 '09 at 0:54

11

I access an API on my own server. I don't want to harm hosts in the internet.
–
ChristianMay 15 '09 at 6:28

11

I've increased the connection limit to build a load test tool. It's really hard to load test with 2 measley connections. I'm sure there are lot's of non-browsing reasons to use many connections.
–
ScottSMay 15 '09 at 6:30

1

BTW, the config above will affect all .Net controlled connections, not just webclient.
–
ScottSMay 15 '09 at 6:33

IMHO that setting the System.Net.ServicePointManager.DefaultConnectionLimit is a better solution, as cannot assume that the WebRequest is a HttpWebRequest, e.g., it could be a FileRequest.
–
DennisDec 1 '11 at 17:48

If you find the ServicePoint object being used by your WebClient, you can change its connection limit. HttpWebRequest objects have an accessor to retrieve the one they were constructed to use, so you could do it that way. If you're lucky, all your requests might end up sharing the same ServicePoint so you'd only have to do it once.

I don't know of any global way to change the limit. If you altered the DefaultConnectionLimit early enough in execution, you'd probably be fine.

Alternately, you could just live with the connection limit, since most server software is going to throttle you anyway. :)

This server will not throttle me (in fact, it will, but in a different way) as it is completely under my control
–
ChristianMay 15 '09 at 6:27

A server might throttle with a lot of connections, but I haven't experienced that even with a small server (hosted in a limited VM). The limit 2 on the client side held me back on the other hand. Increasing the limit liberated the situation.
–
Csaba TothApr 3 '13 at 18:10

1

I also doubt that any of today's browser would obey to the HTTP 1.1 RFC's limit of 2.
–
Csaba TothApr 3 '13 at 18:18