Re: HTTP Web Response Exception - I cant able to trap. Intermittent error With HTTPWebRequest
We have a service which runs at one hour and checks if configured URI's are working (UP) or not. We have around 10 URI's to check.
Strangely for for one particular URI which is giving intermittent error:
Error Message : The underlying connection was closed: Unable to connect to the remote server.
Error Source : System
Error Exception : System.Net.WebException: The underlying connection was closed: Unable to connect to the remote server.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult asyncResult)
at System.Net.HttpWebRequest.GetResponse()
Generally this error we get when we the destination website is down. But thats not the case the website is fully functional.
Here is my code:
StreamReader objSR = null;
HttpWebRequest objRequest = null;
HttpWebResponse objResponse = null;
try
{
objRequest = (HttpWebRequest) HttpWebRequest.Create(ser.ServiceInfo.Name.ToStrin g());
objResponse = (HttpWebResponse) objRequest.GetResponse();
objSR = new StreamReader(objResponse.GetResponseStream(), System.Text.Encoding.ASCII);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
Pls let us know if there is something wrong..or any alternate solution!!!! |