Having an issue, where calling WebRequest.GetResponse()
hangs and times out on the first call, but after the first call, everything works fine.
try {
WebRequest myHttpWebRequest = WebRequest.Create(@"http://192.168.x.x/");
// Sends the HttpWebRequest and waits for the response.
myHttpWebRequest.Timeout = 1000;
WebResponse myHttpWebResponse = myHttpWebRequest.GetResponse();
} catch(Exception e) {
Console.WriteLine("Failure 1");
}
try {
WebRequest myHttpWebRequest = WebRequest.Create(@"http://192.168.x.x/");
// Sends the HttpWebRequest and waits for the response.
myHttpWebRequest.Timeout = 1000;
WebResponse myHttpWebResponse = myHttpWebRequest.GetResponse();
} catch(Exception e) {
Console.WriteLine("Failure 2");
}
try {
WebRequest myHttpWebRequest = WebRequest.Create(@"http://192.168.x.x/");
// Sends the HttpWebRequest and waits for the response.
myHttpWebRequest.Timeout = 1000;
WebResponse myHttpWebResponse = myHttpWebRequest.GetResponse();
} catch(Exception e) {
Console.WriteLine("Failure 3");
}
using this code in a console application, I always receive a Failure 1
. Running under the debugger or not. I've done a 1000 loop, and it always fails on the first one, never any other ones. In fact, reading the logs of the web server, it actually never receives the first request. Am I missing something here?