title: I need help setting .NET HttpWebRequest timeout
body: <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>