"..Connection Closed.." error while connecting to a Web Service
I was repeatedly getting a "Connection closed" error while accessing a web service from a windows client application. This wasn't hapenning on my development machine but on two of the other machines where I am testing. I was totally baffled and my limited knowledge of internet technologies started showing up. But I am one of those that will continue to bang my head against the wall till either my head or the wall breaks, so I started looking out to "The Net" and sure enough, google shows me the most relevant pages and I get the solution.
Apparently, since I was kind of pulling a little more data down the wire, it was timing out, so I needed to keep it 'alive', I added the following to the references.cs
using System.Net; // this had to be typed
....
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);
webRequest.KeepAlive = false;
webRequest.ProtocolVersion=HttpVersion.Version10;
return webRequest;
}
Source : http://p2p.wrox.com/topic.asp?TOPIC_ID=4858 posted by
misrasandeep
So far, its worked and I am not getting "Connection Closed" error anymore. I would be really obliged if someone help me out with understanding this problem and the above mentioned solution.
Thanks in advance.
By the way, I typed this blog using Lutz Roeder's Writer.