By Bagherani


2019-10-09 14:11:35 8 Comments

I'm trying to open about 25connections to a host at the same time.
My OS is windows 10.
For testing, I bring up a simple website on my local IIS and I response a simple data to the user with a delay of 2 seconds using Thread.Sleep(2000).

Now using this code on the client:

const int len = 25;
for (int i = 0; i < len; i++)
{
    new Thread(new ParameterizedThreadStart((idx) =>
    {
        // start downloading data.
        var res = new WebClient().DownloadString("http://192.168.1.101:8090/");

        // log index and time when done.
        Console.WriteLine($"{Convert.ToInt32(idx).ToString("00")} done at:{ DateTime.Now.ToString("HH:mm:ss:ffff") }");
    })).Start(i);
}

I got the following result:

Thread 01 done at 40:8476 ms
Thread 00 done at 40:8476 ms
Thread 03 done at 40:8496 ms
Thread 04 done at 40:8496 ms
Thread 02 done at 40:8506 ms
Thread 05 done at 40:8506 ms
Thread 07 done at 40:8516 ms
Thread 06 done at 40:8516 ms
Thread 08 done at 40:8536 ms
Thread 09 done at 40:8545 ms
Thread 11 done at 42:8510 ms
Thread 10 done at 42:8510 ms
Thread 12 done at 42:8560 ms
Thread 14 done at 42:8560 ms
Thread 15 done at 42:8570 ms
Thread 13 done at 42:8580 ms
Thread 16 done at 42:8590 ms
Thread 17 done at 42:8590 ms
Thread 18 done at 42:8610 ms
Thread 19 done at 42:8610 ms
Thread 21 done at 44:8565 ms
Thread 20 done at 44:8565 ms
Thread 23 done at 44:8634 ms
Thread 24 done at 44:8654 ms
Thread 22 done at 44:8654 ms

The above result tells us that:
1- Thread 0 to 9 got the data at the same time.(second 40)
2- Thread 10 to 19 got the data at the same time 2 seconds later after previous step.(second 42)
3- Thread 20 to 24 got the data at the same time. 2 seconds later after previous step.(second 44)

Now my question is WHO limited me and why it only opens 10 HTTP connections at the same time and how can I set it to unlimited.
If there is any other platform or programming language it will be welcomed.

1 comments

@CodeCaster 2019-10-09 14:15:19

Who? Your OS and web server manufacturer, being Microsoft.

Why? Because Windows 10 is a client OS, and Microsoft doesn't want you to host any serious web applications on that.

See for example:

And from While using signalr, will there be any connection limits on IIS, linking to the SignalR documentation:

When SignalR is hosted in IIS, the following versions are supported. Note that if a client operating system is used, such as for development (Windows 8 or Windows 7), full versions of IIS or Cassini should not be used, since there will be a limit of 10 simultaneous connections imposed, which will be reached very quickly since connections are transient, frequently re-established, and are not disposed immediately upon no longer being used. IIS Express should be used on client operating systems.

There are other posts, like Does windows 10 connection limit apply to self-hosted applications?, mentioning 20 connections, but that's 20 devices (probably recognized by remote IP address) connecting to selected Windows service (SMB, IIS, ...).

The IIS limit is 10, and has been for many years, I think since Windows 7.

So the first half of the answer to this question is:

  • If you need more than 10 simultaneous incoming HTTP connections while developing on Windows 10, use IIS Express or any other web server than IIS or Cassini.

But there's a second half of this answer. If you need more than 10 (or 2, or ..., depending on the environment) simultaneous outgoing HTTP connections, there's ServicePointManager who manages this. See:

So change the limit before executing the requests:

System.Net.ServicePointManager.DefaultConnectionLimit = 25;

Related Questions

Sponsored Content

8 Answered Questions

[SOLVED] How are parameters sent in an HTTP POST request?

6 Answered Questions

[SOLVED] Custom HTTP headers : naming conventions

  • 2010-08-24 21:59:38
  • Julien Genestoux
  • 334620 View
  • 1036 Score
  • 6 Answer
  • Tags:   http http-headers

19 Answered Questions

[SOLVED] How to use threading in Python?

34 Answered Questions

[SOLVED] What is the difference between a process and a thread?

19 Answered Questions

[SOLVED] HTTP GET with request body

  • 2009-06-10 20:47:24
  • Evert
  • 950609 View
  • 1852 Score
  • 19 Answer
  • Tags:   rest http http-get

23 Answered Questions

[SOLVED] What is a daemon thread in Java?

42 Answered Questions

[SOLVED] "implements Runnable" vs "extends Thread" in Java

10 Answered Questions

[SOLVED] HTTP status code for update and delete?

47 Answered Questions

[SOLVED] How do I update the GUI from another thread?

11 Answered Questions

Sponsored Content