As per our requirements we have a web service which internally connects
(Simple HTTP Post Request) to a remote server to initiate some work. We are
calling the web service method asynchronously from a .NET Web Application
hosted on IIS. In our setup the web request form a client can be running for
long duration (may be more than 4 hours).
We are getting exceptions during the HTTP send/receive inside the web
service method. The exception are coming only during high load (for instance
when the pending web request count exceeds 45). For each web request the web
service internally do 10 iterations of Http send/receive (each iteration uses
a new Http connection). There is no fixed pattern in the type of exception
raised.
Following exceptions are coming:
1. The underlying connection was closed: An unexpected error occurred on a
receive
Status of Web Exception: ReceiveFailure
2. The underlying connection was closed: An unexpected error occurred on a
send
Status of Web Exception: SendFailure
3. The underlying connection was closed: Unable to connect to the remote
server
Status of Web Exception: ConnectFailure
4. The underlying connection was closed: The request was canceled
Status of Web Exception: RequestCanceled
I am using .NET Framework 1.1
Web Service and web application both are written in .NET and hosted on
Win2003. I had tested replacing web application with windows application but
got no improvement.
I have also observed that number RequestCancled exception has decreased once
we moved our web service form Win2000 Server to Win2003 Server.
I have tried the .NET bug fix by setting *keepalive* to false but still
getting exceptions.
I had modified the .NET config timeout settings to higher values.
<CODE>
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("URL");
webRequest.KeepAlive = false;
webRequest.ProtocolVersion=HttpVersion.Version10;
webRequest.Timeout = timeOut;
webRequest.Proxy = GlobalProxySelection.GetEmptyWebProxy();
webRequest.Method = "POST";
webRequest.ContentType="application/x-www-form-urlencoded";
StreamWriter myWriter = new StreamWriter(webRequest.GetRequestStream());
myWriter.Write("some post Data");
myWriter.Close();
WebResponse httpWebRes = httpWebRequest.GetResponse();
// Do some work with httpWebRes
httpWebRes.Close();
</CODE>
Thanks in advance.
--
Cheers,
Rahul Anand