System.Net.Webclient and more than 2 connections threaded

F

Fredrik Arenhag

Hi!

I'm in the process of developing an application for downloading files
from a webserver. This is done in a threaded manner, but how hard I ever
try I can't seem to manage to get more than 2 threads to download at the
same time.

If I launch more than two threads they all start, but only the first two
actually download something. When the first thread completes the third
one happily starts working.

I remember someone somewhere telling me that there was some built in
restriction in win32-platforms that there could not be any more than 2
concurrent http-connections, but I can't seem to find this information
anymore.

Does anyone know if this is the problem and how I might solve it, or if
there is another underlying problem to these symptoms?

TIA!
/Fredrik Arenhag
 
C

Cor

Hi Frederik,

It is working with HTTP1.1 when you search for it you will see that that
allows standard only 2 files to download.

Cor
 
F

Fredrik Arenhag

Thank you Cor for your fast response!

So as it looks now this is just something I will have to accept, or is
there some way around this? Registry?

TIA
/Fredrik Arenhag
 
D

David Browne

Cor said:
Hi Frederik,

It is working with HTTP1.1 when you search for it you will see that that
allows standard only 2 files to download.

This has nothing directly to do with the HTTP standard. IE, and many other
clients will only open 2 connections per server per session. By default the
WebClient does the same.

This behavior is controled by the following config setting:

<system.net>
<connectionManagement>
<add address="*" maxconnection="2"/>
</connectionManagement>
</system.net>

Which means that for any web host, a maximum of 2 connections will be opened
per application (AppDomain).

You can change this in machine.config, or override it in your application
config.

David
 
F

Fredrik Arenhag

Thanx David!
I'll try this out as soon as I've solved some stupid permission problems
in my ASP.NET application =)

/F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top