Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6123241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:59:33+00:00 2026-05-23T15:59:33+00:00

Having an issue, where calling WebRequest.GetResponse() hangs and times out on the first call,

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:59:33+00:00Added an answer on May 23, 2026 at 3:59 pm

    EDIT: I’ve realised the answer below would fit with the exact opposite situation, where the first request works but the others don’t. However, it’s still important – you really should be disposing of your responses. It would also be useful if when you report the error, you also report the exception message…

    To work out what’s going on here, you should really use something like WireShark so you can see whether the problem is that the request is being made but not responded to, or whether it’s not even being made.

    I wonder whether the problem is actually that it’s resolving a proxy, or something like that… and there’s just about enough time to resolve it before the second request times out. Try increasing the timeouts. Again, this should be visible via WireShark.


    You’re not disposing of the web response, so the connection pool for the second request is going to time out waiting to get that connection back.

    Put the WebResponse part in a using statement and you’ll probably find it all works fine:

    using (WebResponse myHttpWebResponse = myHttpWebRequest.GetResponse())
    {
    }
    

    That’s assuming you’d actually do something with the response, of course. Otherwise you could just write:

    myHttpWebRequest.GetResponse().Dispose();
    

    🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having an issue here that I have tried everything I can think of but
I'm having an issue with calling a method on a UserControl. Hear me out:
I'm having an issue calling a method from a separate project within the same
Hi All I am currently having an issue calling a WCF service from a
i am having issue with loading my selector via a jquery ajax load call
Having an issue with traversing in jQuery.. hopfully an easy one..but I'm banging my
Im having an issue where the my jquery UI dialog loads multiple times on
I'm having an issue when calling 32 bit Delphi DLL files from a C#
I am having an issue trying to figure out how to appropriately name my
I am having an issue when using the jQuery $.getJSON ajax call, though the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.