An Unexpected Error Occurred On A Receive. System.io.ioexception
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Web Service Unexpected Error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection up vote 0 down vote favorite We have a web service hosted on Windows2003 32bit. Now that we have moved to a Windows 2008 64bit server, calls to the web service return the following error (from client machines as well as from a 'client' exe running on the server (so it can't have anything to do with networking)): 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.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) at WindowsFormsApplication1.hytapps.utilitiesclass.Logon(String Operator, String OperatorPassword, String CompanyId, String CompanyPassword, Language LanguageCode, LogDetail LogLevel, Instance EncoreInstance, String XmlIn) in C:\Users\shawnd\AppData\Local\Temporary Projects\WindowsFormsApplication1\Web References\hytapps\Reference.cs:line 93 at WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e) in C:\Users\shawnd\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs:line 25 Any ideas please? .net web-services share|improve this question edited May 27 '
Convert HTML to Wikipedia format System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. RSS Reader Blog The horror of no source control Post Categories .NET AOP Blog Games German WWF TechEd EMEA 2007 Archives November 2011 (1) September 2009 (1) June 2009 (1) October 2008 (2) May 2007 (1) February 2007 (1) January 2007 (2) December 2006 (1) May 2006 (1) February 2006 (2) http://stackoverflow.com/questions/6156176/web-service-unexpected-error-occurred-on-a-receive-system-io-ioexception January 2006 (1) August 2005 (2) July 2005 (2) Denis Pitcher Denis Pitcher's Tech Blog << RSS Reader | Home | Convert HTML to Wikipedia format >> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. Comments (63) | Share System.Net.WebException: The underlying connection was closed: An unexpected error http://geekswithblogs.net/Denis/archive/2005/08/16/50365.aspx occurred on a receive. I've been trying to figure out what the cause of this problem is for a few days now and I've finally tracked down the error. It's due to a bug in .net that closes the connection prior to it being finished. I'm concerned about the performance issues involved in reconnecting, however I have written my code to keep most connections and data transfer small anyways, I'll have to keep an eye on the performance of this crappy bug. A good reference for solving this issue is available at: http://p2p.wrox.com/topic.asp?TOPIC_ID=4858 Unfortunately the microsoft KB article that addressed the issue is no longer available. As suggested I have added the following code to my reference.cs file (which needs to be done each time I update the webservice reference) to assign the keepalive value to false to allow the connection to be closed and reopened. protected override WebRequest GetWebRequest(Uri uri){HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);webRequest.KeepAlive = false;webRequest.ProtocolVersion=HttpVersion.Version10;retu