Bug 4133 - ServicePointManager.DefaultConnectionLimit is not obeyed
Summary: ServicePointManager.DefaultConnectionLimit is not obeyed
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web (show other bugs)
Version: 2.10.x
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-03-28 16:37 UTC by Joe
Modified: 2012-03-28 16:37 UTC (History)
1 user (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Joe 2012-03-28 16:37:52 UTC
ServicePointManager.DefaultConnectionLimit is not obeyed when set to 1.


using System;
using System.IO;
using System.Net;
using System.Threading;

namespace HttpPipelineTest
{
    class Program
    {
        static void Main(string[] args)
        {
            ServicePointManager.DefaultConnectionLimit = 1;
            WaitCallback method = (wc) =>
                {
                    HttpWebRequest req = HttpWebRequest.Create("http://www.google.com/") as HttpWebRequest;
                    req.Pipelined = true;
                    req.KeepAlive = true;
                    using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream()))
                        Console.WriteLine("{0} at {1}. Pipelined: {2}", reader.ReadToEnd().Length, Environment.TickCount, req.Pipelined);
                };
            ThreadPool.QueueUserWorkItem(method);
            ThreadPool.QueueUserWorkItem(method);//pipelining won't be apparent until after the 1st request's response comes back
            ThreadPool.QueueUserWorkItem(method);
            ThreadPool.QueueUserWorkItem(method);
            Console.ReadLine();
        }
    }
}

Note You need to log in before you can comment on or make changes to this bug.