Intermittent WebException "The remote name could not be resolved" -try a few times.

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 @ Monday, August 14, 2006 9:38 AM

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
Please add 5 and 3 and type the answer here:
 

Live Comment Preview:

 
«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910