Note that there are some explanatory texts on larger screens.

plurals
  1. POI need help setting .NET HttpWebRequest timeout
    primarykey
    data
    text
    <p>My objective is to get the answer from up to 6000 Urls in the shortest time. It was working very well (12 seconds for 5200 LAN Addresses) until some delay started to happen.</p> <p>My code uses up to 20 simultaneous HttpWebRequest.BeginGetResponse with <code>ThreadPool.RegisterWaitForSingleObject</code> for timeout handling.</p> <p>However some (up to 4 in 5,000) of the requests never hit the TimeoutCallback function with the second parameter (timedOut) true, and they waste 5 minutes of my precious time until they hit theBeginGetResponseCallback function and then raise a WebException. The exceptions says something like "the operation reached the time limit", but as the exception message is in portuguese(my native language) I couldn't Google it.</p> <p>I wonder if I can reduce this time limit to 20 seconds for example. Anyone knows how? I've already tried:</p> <pre><code>&lt;system.web&gt; &lt;httpRuntime executionTimeout="20"/&gt; &lt;/system.web&gt; </code></pre> <p>But as I'm running it as a Console Application, ASP.NET configurations don't work. And I also tried:</p> <pre><code>myHttpWebRequest.Timeout = 20*1000; </code></pre> <p>And</p> <pre><code>ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), AsyncState, 20*1000, true); </code></pre> <p>Without success. Can you help me?</p> <p><strong>Update</strong> What I am trying to say is there are 4 possible results for an asynchronous HTTP request:</p> <ol> <li>Never reach the callback function -> timeout callback function</li> <li>Reaches and answers successfully</li> <li>Reaches and raises an exception</li> <li>Delay exactly 5 minutes until raise an "time limit" web exception inside the callback function</li> </ol> <p>The 4th possibility is the one is delaying my Application, and I don't know how to shorten that delay</p> <p><strong>Update</strong> Is there a possibility that the method <code>GetResponseStream</code> instead of the <code>GetResponse</code> is who causes the timeout?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload