Re: An existing connection was forcibly closed by the remote host



I finally figured out how to address this specific issue. Within my web service proxy class I overrode the GetWebRequest(uri) method and modified it as shown below.

protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest request = base.GetWebRequest(uri) as HttpWebRequest;
request.SendChunked = true;
return request;
}

What I still haven't taken the time to figure out is why this behavior changed after we applied windows service packs to our machine. If the size of the request message I was using is greater than the size of the packets the host could receive and the host is configured receive chunked messages then I guess I can assume (I hate assuming things) when we sent a message larger than the packet size without sending it chunked their server terminated the session because it was waiting for another TCP message???

Hard to tell without being able to easily work with the web service host directly. At any rate I hope this helps anyone else who encounters the same problem.

"Wil Peck" <wilpeck@xxxxxxxxxxx> wrote in message news:560C82CD-FC87-4FDC-98A8-5565551CD9DD@xxxxxxxxxxxxxxxx
So here is the scenario...

I have a console application executing a Web Method on my WSDL generated System.Web.Protocols.SoapHttpClientProtocol instance using HTTP over a VPN. For some reason requests that are larger than 1024 bytes are timing out and the stack trace ends up being something like the above. I can't find where there are any maxRequestLength (that applies to requests a client makes to a web service) that can be adjusted to accommodate for larger requests.

Below is an snippet of the stack trace minus any proprietary info.

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

I have done a trace on the System.Net.Sockets which seems to show that the request wasn't really completed by the SoapHttpClientProtocol instance. Please note that this was working fine until we applied patches to our Win2k machine and then after the patches were applied it stopped working. I have been able to get the service to work on WinXP fully patched, but not on Windows Server 2k3 or Win Server 2k.

My hunch is the request is never fully written to the host of the web service and the web service finally decides to close the connection because it received an incomplete message. In an attempt to give the request more time to complete I have increased the WebClientProtocol.Timeout to 2 minutes without any success. If anyone has any other ideas on this it would be greatly appreciated.

Thanks - Wil

.



Relevant Pages

  • Re: An existing connection was forcibly closed by the remote host
    ... HttpWebRequest request = base.GetWebRequestas ... the host could receive and the host is configured receive chunked messages ... System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ... at System.Net.Sockets.NetworkStream.Read(Bytebuffer, Int32 offset, Int32 size) ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: BizTalk 2004 SOAP Adapter Tuning, ThreadPool
    ... > either the web service or the host, ... >>a result the connection is timing out. ... >>it executes the request in just a few seconds so you ...
    (microsoft.public.biztalk.general)
  • RE: BizTalk 2004 SOAP Adapter Tuning, ThreadPool
    ... either the web service or the host, ... BUT i dont believe it is the right way of doing it, ... >second, third, ..., request all executing the same web ...
    (microsoft.public.biztalk.general)
  • The server committed a protocol violation
    ... My web server has both NTLM and Basic authentication. ... application can access the web service without any problems. ... Host: 150.158.204.40 ... Request -> ...
    (microsoft.public.dotnet.framework.webservices)
  • The server committed a protocol violation
    ... My web server is a Windows CE 4.2 device ... application can access the web service without any problems. ... Host: 150.158.204.40 ... Request -> ...
    (microsoft.public.dotnet.framework)

Loading