The underlying connection was closed: An unexpected error occurred on a receive. (Web Service)
We had a web service which was working without any problem for few months and suddenly last week it started to give the above mentioned error. Even though I found some similar threads on the web, nothing helped me to solve the problem.
After few hours of R&D I found a workable solution! Overriding the web service's proxy class fixed the error where I’ve created a new HttpWebRequest.
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
//Get a new HttpWebRequest
System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(uri);
webRequest.KeepAlive = false;
return webRequest;
}