Exception while calling .NET web service | System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host



We have written a .NET web service which retrieves an xml file from the database. This web service is SSL secured and requires client certificates for connection.



The web service is throwing an exception while retrieving large files. It works fine when the file size is around 1 MB, but fails with a file size of around 65 MB with the following exception:

System.InvalidOperationException: There is an error in XML document (1, 38455668). ---> System.IO.IOException: Unable to read data from the transport connection. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

   at System.Net.Sockets.Socket.BeginReceive(Byte[] buffer, Int32 offset, Int32size, SocketFlags socketFlags, AsyncCallback callback, Object state)

   at System.Net.Sockets.NetworkStream.BeginRead(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)

   --- End of inner exception stack trace ---

at System.Net.Sockets.NetworkStream.BeginRead(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)

   at System.Net.TlsStream.BeginRead(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback asyncCallback, Object asyncState)

   at System.Net.Connection.BeginRead(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)

   at System.Net.ConnectStream.InternalBeginRead(Int32 bytesToRead, NestedSingleAsyncResult castedAsyncResult, Boolean fromCallback)

   at System.Net.ConnectStream.BeginReadWithoutValidation(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)

   at System.Net.ConnectStream.BeginRead(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)

   at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size)

   at System.IO.StreamReader.ReadBuffer(Char[] userBuffer, Int32 userOffset, Int32 desiredChars, Boolean& readToUserBuffer)

   at System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32 count)


The web service fails after around 120 seconds.


Steps taken without success:


  1. Added a key DefaultTTL with value 255 in registry under HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters to increase the time out period of the TCP/IP connection but it didn’t help. The web service again fails after around 2 minutes.
  2. Checked that the web service is not getting timed out. Timeout property is specifically set to a large value before calling the web service using webservice.Timeout property.
  3. Applied a hotfix for .NET Framework from Windows which was to fix a very similar problem. Following is the information about the same:

887563 Availability of the .NET Framework 1.1 Post-Service Pack 1 rollup package for System.dll. However, this didn’t fix the problem.


Any pointers to resolve the problem will be appreciated!

5/3/2005 12:37:22 PM
asp.net.xml-web-services 7071 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 32

Are you using IIS6.  If you are the script timeout in IIS applies to both ASP and ASPX pages (in IIS 5 it only applies to ASP pages), simply open your admin console and change the script timeout for your virtual directory.

Hope that fixes it.



My Blog: http://www.wintersfamily.plus.com/blogs/JamesWinters
5/4/2005 4:07:05 PM

Having gone to look at IIS again, the default HTTP connection timeout is 120s.  Seems to be a candidate as well.

Open IIS Manager > Default Web Site > Properties.  Connection Timeout appears on the Web Site tab.




My Blog: http://www.wintersfamily.plus.com/blogs/JamesWinters
5/4/2005 4:51:27 PM

Similar Artilces:

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

When runnig Web Service asynchronously
When I try to call web service asynchronousIy I am getting exception from CLR: System.Net.Sockets.SocketException: The attempted operation is not supported for the type of object referenced. (During VS.NET debugging the exception is wrapped as: Unable to connect to the remote server) When i call the service synchronously it works perfectly.  The service just convert strings to lower case. I'm using .NET Framework 2.0, here is the source code of form to call the service asynchronously:   Imports localhost Partial Class ChangeStrings Inherits System.Web.UI....

Web service in .NET from Java Web Service
Hi there,I'm pretty new to .net (although i have years of experience with the old vb 6, access 2k, as well as java)... and need some with perhaps either some syntax or something.Here is the wsdl.<wsdl:definitions targetNamespace="http://www.dynix.com/schema/book">−<wsdl:types>−<schema targetNamespace="GetBookInfoByISBN">−<complexType name="BookInfoType">−<sequence><element maxOccurs="1" minOccurs="0" name="Title" nillable="true" type="xsd:string"/><element maxOccurs=&quo...

Can you return .net web controls in a .net page from a web service?
I've got a problem with a project. I've got to compile an entire .net page and return it as part of a Web Service for display. The problem I have is that I need to add WebControls and functionality to the page so that not only the html content and images are displayed (which I've managed) but that textboxes, labels, buttons and datasets can be displayed also. Essentially I need to make a call from one site for a page, populate the page and return it in a state as though it resided on the same server/webspace as the calling page. Code is currently built as follows into a string: strOpenHT...

System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
I'm getting this error when hitting a webservice thousands of times for a mass upload. I've researched on the web and added the suggested code but am still getting the error: protected override WebRequest GetWebRequest(Uri uri) { System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)base.GetWebRequest(uri); webRequest.KeepAlive = false; return webRequest; }  Are you receiving it on the client, or on the service?John Saunders | MVP – Connected System Developer...

An existing connection was forcibly closed by the remote host
While Calling a web service I am getting following error. This happens when I made some changes in the .asmx file and copy updated web reference (wsdl file) and asmx file on the staging server. Things are working fine in the development environmet. Server Error in '/' Application. An existing connection was forcibly closed by the remote host Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: S...

.NET web services Vs Java Web Services
Hello, does anyone know of a book or good source of information that compares .NET and Java Web Services? (I would like soemthing neutral if possible). I am thinking of approaching this subject for my dissertation? Many Thanks Rob Hi Rob, Last year I had to give a powepoint presentation on Web Services. I noticed some good books at barnes and noble that discussed the subject. These books were specific to Java and discussed Web Services in a very clear fashion. They gave some elementary examples that were easy to understand. I have not yet had the pleasure of creatin .NET Web Servi...

How to call .net web service from Java web application?
Hi all,  I have a vb .net web service.How do i call .net web service from Java web application?What all resources I need?Can you please provide a sample application where a java application is invoking methods of .net web service? Thank you Hi, First I am not familiar with java language, but web services are universal operating system and language independent. It doesn't matter where the services is or in what language is written you just invoke it  and it gives you "replay".  Probably you must reffer to java consuming web services.   Regard...

.NET Web Service and Non .NET programe
When we develop a web service by VB.NET. Then i use visual basic, Microsoft access, asp. Can these stuff access to my web service ? Means you want to access Webserver developed in VB.NET in ASP application?Sreedharhttp://www.w3coder.orgweblog http://weblogs.asp.net/skoganti...

Best Practice for .Net Web Service access to a Web Service on a Test and Production Servers
Hello All, What is the best way to control a .Net web service to be able to access a remote server for testing and then point to another remote server to access the web service in production? Do I need to generate and maintain 2 different proxy objects? TIA, Bob Bob // first create the proxy if not isvalid( i_service) then i_service = create fundtraderproxy_TradeServicesClient_BasicHttpBinding_ITradeServices end if ///You'll see code something like this in the constructor of your proxy //dynamically set the endpoint url with the user supplied value - //r...

.NET Web Service Proxy (EasySoap vs .NET)
Greetings all, I was provided with a URL for a web service that is password protected. I saved the WSDL file from the browser and am attempting to create a .NET Web Service Proxy to use it. When I select EasySoap for the 'Web Service Selection', I see one service ('Services') and five 'Structures' (which is the number of 'methods' that I am expecting to see). But when I select .NET, I still see one service (named differently) and only one structure. Four of the structures are missing. Is there something else I need to do to view the four ...

I develop in .net and need to create a web client to connect to a web service built in Java. http://xchainj.com:8080/axis/services/ScsEnvirodatWaterQualityIndexServiceSoap Its pretty easy when the web service was also built in .net. You can just create a web reference with the gui and automatically can see its functions and stuff. when i put this url in the box and hit go i dont get to see its functions. maybe this shouldnt be the url of the WSDL?? I Have no idea. Im very new to all of this. If there are any examples of .net clients connecting to non .net web clients it woul...

web services calling services simultaneosly problem in .net 2.0
hi i m facing a problemwe are using desktop client and webservices in that client request the a webservice asyncthat remains on server until a specific condition is satisfiedand rest of the web services are called syncronsly these services run on localhost without any problembut if client and server machines are diffrent it hangs the applicationdont knw wht is the reasn and after some time operation has timed out exceptions comelet me tell u one more thingboth the services are using different sessionsthanx in advance for ur help   i have made sample application to test the scnerio...

What do non-.net users need to do to consume a .net web service?
Hello, I'm very new to web service world and haven't had much chance to do much reading on theory and architecture yet. So I'm asked to create one for someone external to my organization (still inside my company). I make one, test it, deploy it, consume it. Go me. It was very easy within my comfortable .net shop. However, the intended consumer is not a .Net shop (J2EE). I was under the impression that if I sent in a GET request to the asmx file, I would get XML back. This turned out to be not the case and I had to use the proxy file to prove that I could consume the service. S...

Web resources about - Exception while calling .NET web service | System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host - asp.net.xml-web-services

Resources last updated: 12/12/2015 5:58:43 PM