Note that there are some explanatory texts on larger screens.

plurals
  1. PODifference between operation has time out and (504) Gateway Timeout
    primarykey
    data
    text
    <p>I am using <code>HttpWebRequest</code> in my application which is checking some URI's in multiple threads. I am getting multiple types of time out exceptions. </p> <ul> <li>The operation has timed out</li> <li>The remote server returned an error: (504) Gateway Timeout.</li> </ul> <p>Their details are like:</p> <blockquote> <p>System.Net.WebException: The operation has timed out at System.Net.HttpWebRequest.GetResponse() at ......</p> </blockquote> <p>and </p> <blockquote> <p>System.Net.WebException: The remote server returned an error: (504) Gateway Timeout. at System.Net.HttpWebRequest.GetResponse() at ....</p> </blockquote> <p>What is the different between these two. </p> <p>My function is like:</p> <pre><code>public bool CheckUri(Uri m_url) { try { HttpWebRequest request = HttpWebRequest.Create(m_url) as HttpWebRequest; request.UserAgent = "MyUserAgent"; //For: The underlying connection was closed: An unexpected error occurred on a receive. request.KeepAlive = false; request.ProtocolVersion = HttpVersion.Version10; request.Method = "HEAD"; //Get only the header information using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { int statusCode = (int)response.StatusCode; if (statusCode &gt;= 100 &amp;&amp; statusCode &lt; 400) //Good requests { string sContent = null; using (var stream = response.GetResponseStream()) using (StreamReader loResponseStream = new StreamReader(stream)) sContent = loResponseStream.ReadToEnd(); return true; } else { return false; //hard to reach here } } } //vexing exception catch (WebException ex) { if (ex.Status == WebExceptionStatus.ProtocolError) //400 errors { var response = ex.Response as HttpWebResponse; if (response != null) { Console.WriteLine("HTTP Status Code: " + (int)response.StatusCode); Console.WriteLine(response.StatusCode); } } else { Console.WriteLine(ex.Message); } return false; } catch (Exception ex) { Console.WriteLine(ex.Message); return false; } } </code></pre> <p>Also If anyone could tell me, would there be an issue if multiple threads call this method with different URIs. I am not getting any cross thread exception. This method is actually a part of a windows service which monitors a list of almost 200 URIs. </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