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 6965307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:02:44+00:00 2026-05-27T16:02:44+00:00

I’m playing around with the HttpWebRequest class and got confused about the Timeout/ReadWriteTimeout members.

  • 0

I’m playing around with the HttpWebRequest class and got confused about the Timeout/ReadWriteTimeout members. The issues is that the ReadWriteTimeout gets ignored sometimes and then my application hangs exactly 5 minutes on my GetResponse() call. Sometimes it simply throws a WebException and sometimes it hangs for 5 minutes, which seems to be the default value. I even check the ReadWriteTimeout value before calling GetResponse() and it’s always the correct value, which I set to 10000.

var getPage = WebRequest.Create(url) as HttpWebRequest;
getPage.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
getPage.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.19) Gecko/20110707 Firefox/3.6.19";
getPage.ProtocolVersion = HttpVersion.Version11;
getPage.Method = "GET";
getPage.CookieContainer = foo;
getPage.Proxy = proxyHTTP;
getPage.Timeout = 10000;
getPage.ReadWriteTimeout = 10000;

// in another function where I pass the getPage to

Console.WriteLine("Timeout: {0} / ReadWriteTimeout{1}", page.Timeout, page.ReadWriteTimeout);

var pageResponse = (HttpWebResponse)page.GetResponse();
Console.WriteLine("It reaches this line after 5 minutes");
if (pageResponse.StatusCode == HttpStatusCode.OK)
{
    // read and close it afterwards
}

I am using a HTTP Proxy. The weird part is that the url loads fine in the browser. I’d be thankful for any input.

// EDIT BELOW

namespace Proxy
{
 class Program
 {
     static void Main(string[] args)
     {
        var htmlResponse = new StringBuilder();
        var RequestPage = BuildHttpRequest("https://twitter.com/signup");
        GetHttpResponse(RequestPage, htmlResponse);
    }
    public static HttpWebRequest BuildHttpRequest(string url)
    {
        try
        {
            var getPage = (HttpWebRequest)WebRequest.Create(url);
            WebProxy proxyHTTP = new WebProxy("201.38.194.50", 3128);


            getPage.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
            getPage.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.19) Gecko/20110707 Firefox/3.6.19";
            getPage.ProtocolVersion = HttpVersion.Version11;
            getPage.Method = "GET";
            getPage.Proxy = proxyHTTP;
            getPage.Timeout = 10000;
            getPage.ReadWriteTimeout = 10000;
            return getPage;
        }
        catch (WebException ex)
        {
            Console.WriteLine(ex.ToString());
        }

        return null;
    }
    public static bool GetHttpResponse(HttpWebRequest page, StringBuilder html)
    {
        html.Clear();
        try
        {
            Console.WriteLine("A");
            var pageResponse = (HttpWebResponse)page.GetResponse();
            Console.WriteLine("5 minutes!");
            if (pageResponse.StatusCode == HttpStatusCode.OK)
            {

                var reader = new StreamReader(pageResponse.GetResponseStream());
                html.Append(reader.ReadToEnd());
                pageResponse.Close();
                reader.Close();
                return true;
            }
            Console.WriteLine(pageResponse.StatusCode.ToString());
            pageResponse.Close();
            return false;
        }
        catch (WebException ex)
        {
            Console.WriteLine(ex.ToString());
        }

        return false;
    }
}

}

    A first chance exception of type 'System.Net.WebException' occurred in System.dll
    System.Net.WebException: The operation has timed out
    at System.Net.HttpWebRequest.GetResponse()
  • 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-27T16:02:45+00:00Added an answer on May 27, 2026 at 4:02 pm

    Can you try this

        var request = (HttpWebRequest)WebRequest.Create(url);
        using (var pageResponse = request.GetResponse())
        {
           // Do stuff with `response` here 
        } 
    // drop the as HttpWebRequest; 
    
    // The response however is, these will eventually be reclaimed by the GC 
    // but you'll run into problems similar to deadlocks if you don't dispose them yourself 
    // when you have many of them 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
i got an object with contents of html markup in it, for example: string
I need a function that will clean a strings' special characters. I do NOT

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.