[Mono-bugs] [Bug 339422] New: System.Net.ServicePointManager. DefaultConnectionLimit not used at all.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Nov 5 21:13:08 EST 2007


           Summary: System.Net.ServicePointManager.DefaultConnectionLimit
                    not used at all.
           Product: Mono: Runtime
           Version: unspecified
          Platform: i386
        OS/Version: openSUSE 10.3
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: io-layer
        AssignedTo: dick at novell.com
        ReportedBy: sloncho at gmail.com
         QAContact: mono-bugs at ximian.com
          Found By: ---

Looks like the runtime does not care what you set for
System.Net.ServicePointManager.DefaultConnectionLimit or what you have in
machine.config file. It always defaults to 2, even if displaying otherwise.

Using mono 1.2.5-10 on openSuse 10.3 x86.

Here is the setup:
1. I have build a mock web page, which just delays the response for 10 seconds
(posting the code behind class):

using System;
using System.Web;
using System.Web.UI;

namespace testWebPage

        public class slowPage : System.Web.UI.Page
                protected override void OnLoad (EventArgs e)
                        base.OnLoad (e);

2. Install this page on separate server, not the one where the test runner will

3. Create a console application TestRunner:
// project created on 11/5/2007 at 6:54 PM
using System;
using System.IO;
using System.Net;
using System.Threading;

namespace TestRunner
        class MainClass
                private static int nrRequests = 0;
                private static object lockObject = new object();
                private static AutoResetEvent waitToFinish = new

                public static void Main(string[] args)
                        Console.WriteLine("MaxConn per machine.config: {0}",

                        string url = null;
                        Console.Write("PageUrl: ");
                        url = System.Console.ReadLine();

                        int nrRuns = 0;
                        Console.Write("Nr. of runs: ");
                        nrRuns = Int32.Parse(Console.ReadLine());

                        System.Net.ServicePointManager.DefaultConnectionLimit =

                        for (int i = 0; i < nrRuns; i++)
                                string fullUrl = url + "?data=" + i.ToString();
                                System.Net.HttpWebRequest request =
                                lock (lockObject)
AsyncCallback(EndResponse), request);
                                        Console.WriteLine("Send: {0}",

                                // System.Threading.Thread.Sleep(500); // 1/2
sec sleep


                private static void EndResponse(System.IAsyncResult ar)
                        HttpWebRequest request = (HttpWebRequest)
                        HttpWebResponse response = null;
                        StreamReader reader = null;

                                response =
                                Stream stream = response.GetResponseStream();
                                reader = new StreamReader(stream);
                        catch (Exception e)
                                Console.WriteLine("Exception: {0}", e);
                                if (reader != null)
                                if (response != null)

                        Console.WriteLine("Received: {0}",

                        lock (lockObject)
                                if (nrRequests == 0)

4. On the machine, where the TestRunner is going to run, edit the
machine.config file, and change the "maxconnection" setting from 2 (the
default) to something else, like 20.

5. Start the runner, and enter a url to the page from (1):

6. Enter some big number of test runs - like 20.

Expected result:
- Output, which says that per machine.config the maxconnections setting is 20
- Output of starting 20 requests to the slow page
- a delay of about 10-11 seconds, then all connections should end almost at the
same time.
- if running "netstat -n" from another console, we should see 20 established
connections to otherserver

Actual result:
- Output for maxconnections - 2 - WRONG
- Output of starting 20 requests - OK
- a delay about 10 seconds
- starting to finish requests - 2 almost at the same time every 10 seconds -
- running "netstat -n" on another console shows only 2 established connections
at the same time to otherserver - WRONG.

The same example, compiled for .Net 1.1 on Windows works as expected, and
honors the machine.config file.

I have run the test agains some other slow web sites, just to be sure - same


Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list