I am testing an endpoint that I am experiencing some issues with.
I am simply using HttpClient
in a loop that performs a request each hour.
var httpClient = new HttpClient();
var message = httpClient.GetAsync(url).Result;
Console.WriteLine(message.StatusCode);
Once in a while I am getting this exception:
System.Net.Http.HttpRequestException: An error occurred while sending
the request. ---> System.Net.WebException: The remote name could not
be resolved: 'xxx'
The experience is that right after the exception, the URL can be accessed. In a browser you simply refresh the page and all is good.
I still haven't got any reports from users experiencing it so I am wondering if it's just a local issue here but could use a little information to help diagnose.
Is there a way to check if The remote name could not be resolved is caused by an DNS issue or by a web server issue from the exceptions? Can I get more information out of HttpCLient
or do I need more advanced diagnostic tools?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…