Using HttpWebRequest, I'm trying to query a secured (negotiate) url behind a load balancing setup in round-robin mode (two IIS 7.5 servers). Seems simple enough, but I have some problems.
The first anonymous request goes on one server and the negotiate part goes on the other. The problem is that it takes about six seconds between these two requests, so it is way too long. Trying to diagnose the delay, I realized that, going through Fiddler's proxy, all the requests went on the same server, so it took less than one second total. If I disable Fiddlers option "reuse server connections", then my requests have the same behavior as without Fiddler and it takes forever.
Googling this, I ended up on this link: http://fiddler2.com/blog/blog/2013/02/28/help!-running-fiddler-fixes-my-app-
I know that Fiddler is using sockets and its own connection pool, but is there a way to reproduce the same behavior using .NET HttpWebRequest so that my requests (anonymous and negotiate) will reuse connections and end up on the same server?
Here is a quick test that takes about 70 seconds to complete without Fiddler, and about 2 seconds going through Fiddler...
Also, please note that it isn't a Proxy detection delay and that sticky session are disabled on the 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 Fiddler is plain awesome!
Thanks for any advice.