I have a windows service application which sends some message to another webservice (which intern are sent out as email) and downloads response from the server.
Recently, service is getting stopped once in couple of days. (Eventough exception handlings are included still its not getting caught and service is crashing).
Exception getting logged in Event viewer is as below:
Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Net.WebException Stack: at System.Net.ServicePointManager.FindServicePoint(System.Uri, System.Net.IWebProxy, System.Net.ProxyChain ByRef, System.Net.HttpAbortDelegate ByRef, Int32 ByRef) at System.Net.HttpWebRequest.FindServicePoint(Boolean) at System.Net.HttpWebRequest.get_ServicePoint() at System.Net.AuthenticationState.PrepareState(System.Net.HttpWebRequest) at System.Net.AuthenticationState.ClearSession(System.Net.HttpWebRequest) at System.Net.HttpWebRequest.ClearAuthenticatedConnectionResources()
at System.Net.HttpWebRequest.Abort(System.Exception, Int32) at System.Net.HttpWebRequest.AbortWrapper(System.Object) at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
I have searched a lot but could not find the proper answer. Any help would be appreciated. Code used :
public class DataAPIWebClient : WebClient
{
protected override WebRequest GetWebRequest(Uri uri)
{
WebRequest w = base.GetWebRequest(uri);
w.Timeout = 60000;
return w;
}
}
public string Send(string path)
{
try
{
using (DataAPIWebClient webClient = new DataAPIWebClient())
{
webClient.Credentials = new NetworkCredential("XXX", "YYY");
string reply = webClient.DownloadString(path);
return reply;
}
}
catch (WebException)
{
throw;
}
}