none
HttpWebRequest "The remote server returned an error: (503) Server Unavailable." RRS feed

  • Question

  • Hello!

    I create a simple request to the www.googl.com. But in the cycle it throw exception (The remote server returned an error: (503) Server Unavailable. )

    HttpWebRequest myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create(queryString);
    HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
    StreamReader myStreamReader = new StreamReader(myHttpWebResponse.GetResponseStream(), Encoding.UTF8);
    result = myStreamReader.ReadToEnd();
    myStreamReader.Close();
    myHttpWebResponse.Close(); 
    What reason of the problem? And how to solve this problem?

    TIA
    Monday, May 18, 2009 8:55 PM

Answers

  • This is coming from the Google server, not you.  There's no way to solve it on your end (unless your query is incorrect, and Google throws a 503 in response to this. which I'm pretty certain they don't do).

    Use a try/catch to handle the error when it happens, because it will occasionally happen.  
    David Morton - http://blog.davemorton.net/ - @davidmmorton
    • Marked as answer by Figo Fei Wednesday, May 20, 2009 8:42 AM
    Monday, May 18, 2009 9:50 PM
  • I copied your code and tried it myself (using queryString = "http://www.google.com") and had no problems at all. So if this is a message that you're getting consistantly, you might want to try using the tracert command to see exactly what path your request is taking.
    Bruce Johnson [C# MVP]
    • Marked as answer by Figo Fei Wednesday, May 20, 2009 8:42 AM
    Tuesday, May 19, 2009 2:22 AM

All replies

  • This is coming from the Google server, not you.  There's no way to solve it on your end (unless your query is incorrect, and Google throws a 503 in response to this. which I'm pretty certain they don't do).

    Use a try/catch to handle the error when it happens, because it will occasionally happen.  
    David Morton - http://blog.davemorton.net/ - @davidmmorton
    • Marked as answer by Figo Fei Wednesday, May 20, 2009 8:42 AM
    Monday, May 18, 2009 9:50 PM
  • I copied your code and tried it myself (using queryString = "http://www.google.com") and had no problems at all. So if this is a message that you're getting consistantly, you might want to try using the tracert command to see exactly what path your request is taking.
    Bruce Johnson [C# MVP]
    • Marked as answer by Figo Fei Wednesday, May 20, 2009 8:42 AM
    Tuesday, May 19, 2009 2:22 AM