Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com
Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com
I've noticed that one of web services, that I am using sometimes(usually at the first attempt) returns WebException "The remote name could not be resolved".
I've desided to include re-try code in my call and it made my application more reliable:

                // I beleive that it's a good idea to re-try in case of "The remote name could not be resolved"

                for (int i = 0; i < 3; i++)

                {

                    try

                    {   //call web service

                        ds = ReadRssUrlAsDataSet(timeStart, url);

                        break;

                    }

                    catch (WebException exc)

                    {

                        if (exc.Message.Contains("The remote name could not be resolved"))

                        {  DebugHelper.TracedLine("Attempt " + i.ToString() + " failed." +exc.Message);

                            continue;//try 3 times

                        }

                        throw;

                    }

                }

Posted on Monday, August 14, 2006 9:38 AM ASP.NET | Back to top


Comments on this post: Intermittent WebException "The remote name could not be resolved" -try a few times.

# re: Intermittent WebException "The remote name could not be resolved" -try a few times.
Requesting Gravatar...
that's wone way. did you every resolve what was causing it?
Left by Zed power on Aug 12, 2011 12:57 PM

# re: Intermittent WebException "The remote name could not be resolved" -try a few times.
Requesting Gravatar...
Checking (exc.Status == WebExceptionStatus.NameResolutionFailure) is better, because messages can be localized.
Left by Kalmi on Mar 01, 2013 7:49 AM

Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net