[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


https://bugzilla.novell.com/show_bug.cgi?id=339422

           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);
                        System.Threading.Thread.Sleep(10000);
                        Response.Write(Request["data"]);
                }
        }
}

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

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
AutoResetEvent(false); 

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

                        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 =
50;

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

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

                        waitToFinish.WaitOne();
                }

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

                        try
                        {
                                response =
(HttpWebResponse)request.EndGetResponse(ar);
                                Stream stream = response.GetResponseStream();
                                reader = new StreamReader(stream);
                                reader.ReadToEnd();
                        }
                        catch (Exception e)
                        {
                                Console.WriteLine("Exception: {0}", e);
                        }
                        finally
                        {
                                if (reader != null)
                                        reader.Close();
                                if (response != null)
                                        response.Close();
                        }

                        Console.WriteLine("Received: {0}",
request.RequestUri.AbsoluteUri);

                        lock (lockObject)
                        {
                                nrRequests--;
                                if (nrRequests == 0)
                                        waitToFinish.Set();
                        }
                }
        }
}

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):
http://otherserver/slowpage.aspx

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 -
WRONG
- 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
result.

Cheers


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