HttpWebRequest, Keep-Alive, how is Fiddler?

Using HttpWebRequest, I am trying to request a secure (consistent) URL for setting load balancing in round-robin mode (two IIS 7.5 servers). It seems simple enough, but I have some problems.

The first anonymous request is sent to one server, and the part for negotiations goes to another. The problem is that it takes about six seconds between these two queries, so it takes too long. Trying to diagnose the delay, I realized that, having gone through the Fiddler proxy, all the requests went to the same server, so it took less than one second. If I turn off the Fiddlers parameter "reuse server connections", then my requests will have the same behavior as without Fiddler, and this will take forever.

In this case, I ended this link: http://fiddler2.com/blog/blog/2013/02/28/help!-running-fiddler-fixes-my-app-

I know that Fiddler uses sockets and its own connection pool, but is there a way to reproduce the same behavior using the .NET HttpWebRequest so that my requests (anonymous and consistent) can reuse the connections and get to the same server?

Here is a quick test that takes about 70 seconds to complete without Fiddler, and about 2 seconds goes through Fiddler ...

Also note that this is not a delay in detecting proxies and this sticky session is disabled on nlb.

    public void Main(string[] args)
    {
        int i = 0;

        while (i < 10)
        {
            HttpWebRequest wr = (HttpWebRequest)WebRequest.Create("http://nlb/service.asmx");
            HttpWebResponse response;

            wr.KeepAlive = true;
            wr.UseDefaultCredentials = true;
            response = (HttpWebResponse)wr.GetResponse();

            using (StreamReader sr = new StreamReader(response.GetResponseStream()))
            {
                Console.WriteLine(sr.ReadToEnd());
            }

            response.Close();

            i++;
        }
    }

This is another proof that the Violinist is just amazing!

Thanks for any advice.

+4
1

, , , -

Response.Close(). .NET 4.5 , " ".

.NET 4.5 :

HTTP.

http://msdn.microsoft.com/en-us/library/system.web.httpresponse.close(v=vs.110).aspx

, .NET 4.5 HttpResponse; , , Connection.Close() Keep-Alive; Fiddler, (, ), . .

0

All Articles