Share via


HttpException (0x80004005): Request timed out - (ignores executionTimeout)

Question

Friday, October 19, 2007 6:04 PM

We have a website that has a few pages that need to be pre-built (for purposes of cache) when the server reboots.  (don't ask why, it's a long story, not my idea).  I wrote a very simple app (see code below) that just pre-loads the pages.  This app runs as a webpage, but it always times out at about 2 minutes.   I expect that because of the number of pages it is loading, it may run for 10 or 15 minutes.  I run this locally on the server, and no proxy is involved.  No matter what I do, I can't get past the timeout above.  It just appears to me, that my page is ignoring the timeout value.  Any help appreciated.

I have the following line in web.config

  <system.web>
    <httpRuntime maxRequestLength="102400" executionTimeout="6000" />

Event log:

Event code: 3001
Event message: The request has been aborted.
Event time: 10/19/2007 4:44:52 PM
Event time (UTC): 10/19/2007 9:44:52 PM
Event ID: ad0d7015b94042fbb7be871cba8df48b
Event sequence: 255
Event occurrence: 1
Event detail code: 0
 
Application information:
    Application domain: /LM/W3SVC/1/ROOT-89-128373033403593750
    Trust level: Full
    Application Virtual Path: /
    Application Path: D:\Home\WWW\
    Machine name: ELKAYLS1P
 
Process information:
    Process ID: 3828
    Process name: w3wp.exe
    Account name: NT AUTHORITY\NETWORK SERVICE
 
Exception information:
    Exception type: HttpException
    Exception message: Request timed out.
 
Request information:
    Request URL: http://localhost/PreloadPages.aspx
    Request path: /PreloadPages.aspx
    User host address: 127.0.0.1
    User: 
    Is authenticated: False
    Authentication Type: 
    Thread account name: NT AUTHORITY\NETWORK SERVICE
 
Thread information:
    Thread ID: 405
    Thread account name: NT AUTHORITY\NETWORK SERVICE
    Is impersonating: False
    Stack trace:
 
 
Custom event details:

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

 

 

Code:

        try
        {
            HttpWebRequest fileRequest = (HttpWebRequest)WebRequest.Create(thisURL + thisPage);
            fileRequest.Timeout = 1000000;
            HttpWebResponse fileResponse = (HttpWebResponse)fileRequest.GetResponse();
            fileResponse.Close();
        }
        catch (Exception Ex)
        {
        }

 

All replies (2)

Wednesday, October 24, 2007 4:34 AM ✅Answered

Hi,

From the error message you provided, it seems that the problem is caused by the timeout of your http execution.

Based on my knowledge, this kind of issue is typically occurs when a server-side code function or macro executes for a period of time longer than the maximum timeout period allowed for server-side code execution.

Then the first solution we can see is to increase the executionTimeout settings in your Web.Config.

Second, since you are using HttpWebRequest. Typically, a request to Web uses one worker thread to execute the code that sends the request and one completion port thread to receive the callback from the Web. However, if the request is redirected or requires authentication, the call may use as many as two worker and two completion port threads. Therefore, you can exhaust the managed ThreadPool when multiple Web service calls occur at the same time. For example, suppose that the ThreadPool is limited to 10 worker threads, and all 10 worker threads are currently executing code that is waiting for a callback to execute. The callback can never execute because any work items that are queued to the ThreadPool are blocked until a thread becomes available.

Third, other potential source of contention is the maxconnection parameter that the System.Net namespace uses to limit the number of connections. Generally, this limit works as expected. However, if many applications try to make many requests to a single IP address at the same time, threads may have to wait for an available connection.

To resolve these problems, you can tune the following parameters in your Machine.config file to best fit your situation:

• maxWorkerThreads
• minWorkerThreads
• maxIoThreads
• minFreeThreads
• minLocalRequestFreeThreads
• maxconnection
• executionTimeout

For more information, you can refer the following link:

http://support.microsoft.com/kb/821268 
(Although the passage is concerning on calling for a WebService, but it also applies to applications that make HttpWebRequest requests directly).

Hope that help.

Thanks.


Wednesday, October 24, 2007 11:52 AM

Thanks, this helps me get a direction to look.