Click here to Skip to main content
15,868,014 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi ,
I am gettgin following exception in my WCF service.

The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9355444'.


Server App config

C#
<system.serviceModel>
   <bindings>
     <netTcpBinding>
       <binding name="tcpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
         <security mode="None">
           <transport clientCredentialType="None" protectionLevel="None" />
           <message clientCredentialType="None" />
         </security>
       </binding>
     </netTcpBinding>
   </bindings>
   <services>
     <service behaviorConfiguration="CatWcfServiceLibrary.Service1Behavior"
       name="CatWcfServiceLibrary.CATService">
       <endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpBinding"
         name="epNetTcp" contract="CatWcfServiceLibrary.ICATService" behaviorConfiguration="CatWcfServiceLibrary.Service1Behavior" />
       <endpoint address="" binding="basicHttpBinding" name="epBasicHttp"
         contract="CatWcfServiceLibrary.ICATService" />
       <endpoint address="mex" binding="mexHttpBinding" name="epMex"
         contract="IMetadataExchange" />
       <host>
         <baseAddresses>
           <add baseAddress="http://localhost:8082/CatWcfService" />
           <add baseAddress="net.tcp://localhost:8083/CatWcfService" />
         </baseAddresses>
       </host>
     </service>
   </services>
   <behaviors>
     <serviceBehaviors>
       <behavior name="CatWcfServiceLibrary.Service1Behavior">
         <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
         <!-- To avoid disclosing metadata information,
         set the value below to false and remove the metadata endpoint above before deployment -->
         <serviceMetadata httpGetEnabled="True"/>
         <!-- To receive exception details in faults for debugging purposes,
         set the value below to true.  Set to false before deployment
         to avoid disclosing exception information -->
         <serviceDebug includeExceptionDetailInFaults="true" />
       </behavior>
     </serviceBehaviors>
   </behaviors>
 </system.serviceModel>



Client App.Config


C#
<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding name="epBasicHttp" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
        <security mode="None">
          <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
          <message clientCredentialType="UserName" algorithmSuite="Default"/>
        </security>
      </binding>
    </basicHttpBinding>
    <netTcpBinding>
      <binding name="epNetTcp" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
        <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
        <security mode="None">
          <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
          <message clientCredentialType="Windows"/>
        </security>
      </binding>
    </netTcpBinding>
  </bindings>
  <behaviors>
    <endpointBehaviors>
      <behavior name="endpointBehavior">
        <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
      </behavior>
    </endpointBehaviors>
  </behaviors>
  <client>
    <endpoint address="net.tcp://catvmappdev01:8083/CatWcfService" binding="netTcpBinding" bindingConfiguration="epNetTcp" behaviorConfiguration="endpointBehavior" contract="ICATService" name="epNetTcp"/>
    <endpoint address="http://catvmappdev01:8082/CatWcfService" binding="basicHttpBinding" bindingConfiguration="epBasicHttp" contract="ICATService" name="epBasicHttp"/>
  </client>
</system.serviceModel>


I have around 5000 plus records coming from my Method.

Please HELPPP

"Happy coding"
Posted
Comments
Murali Krishna Chaturvedi 15-Sep-15 8:33am    
I have a weird situation wherein the service is normally working fine but when I'm trying to generate a Web Service Request via Load Runner in TCP, I'm getting the same error as above.

Action.c(16): Error:The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:59:59.9949990'.
Error: An existing connection was forcibly closed by the remote host

Server stack trace:
at System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
at System.ServiceModel.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
at System.ServiceModel.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at HP.WcfRouter.IUniversalContract.Send(Message message)
at HP.WcfRouter.WcfRouter.DoRequestInternal(Boolean isOneWay, Dictionary`2 context)
Action.c(16): Error:InvokeMethod failure: External component has thrown an exception..
Action.c(16): Error:ExtractResultArg failure: Object reference not set to an instance of an object..
Action.c(16): Error:Web service call "GetTopics_101" execution failed

Any help is deeply appreciated.

I have done the config changes suggested wrt to maxItemsInObjectGraph, send and receive timeout as well.

Normally I would say this that error you have is generic and generally hides another fault, not shown by the error.

But in your case, your timeout is so close to a minute, I think you're hitting this limit:

sendTimeout="00:01:00"

Try extending this time and see if it takes longer.

It could, quite simply, be taking longer the 1 minute to generate the server the response.

If not the next step is to trace the actual call. You need to configure a trace and then look into the trace output to find the real exception.

Service Trace Viewer Tool (SvcTraceViewer.exe)[^]


[Edit member="Tadit"]
Link text added to reflect the article title.
[/Edit]
 
Share this answer
 
v3
Comments
TapasU 7-Aug-13 11:13am    
Hi Stephen,
Thanks for the solution. However, I changed the sendTimeout to "00:10:00" but still facing the same issue :(.

I have tried all these.

Increase the ReceiveTimeout and SendTimeout on the binding that is used by your web service to 5 min. The other timeout properties default values are 99.9% always correct. The 5 min is very big and will usually eliminate actual timeout issues.

The usual suspects for the error is MaxBufferSize, MaxBufferPoolSize, MaxReceivedMessageSize, MaxArrayLength default size (65536) is to small. Increase them by adding a 0 at the end (655360) to see if the error disappear. Then by small increments reduce the size to find the correct value.

If your web service method returns an big message or generic array or list with a big items count and big object graph you have to increase the value of the property MaxItemsInObjectGraph in the dataContractSerializer element. You need to create a Service Behaviour (Service side) and Endpoint Behaviour (Client side) with the dataContractSerializer element. You will then see the MaxItemsInObjectGraph property.

To increase your communication between service and client you can switch the TransferMode in the binding from Buffered to Streamed.

When you call the web service from an .Net client please avoid calling your code inside a using statement. Rather use try-finally where you can call close on the client object and if the communication channel faulted you can call abort on the client object.

Please Help
Stephen Hewison 7-Aug-13 11:26am    
Tapas, Thanks for the response. I'm well versed in WCF. I'm a big fan of self hosted WCF n-tier service oriented architectures for enterprise solutions. Unfortunately if that doesn't change the response you're getting then you'll have to run the trace as I've found this is the only way to get to the real error.
TapasU 8-Aug-13 0:02am    
I will try and run the trace and will get back to you.
Hi Stephen,

Finally I got the break through, today morning.
This was the eventual trick.

1. Added these behaviors at both service and client config.

XML
<behaviors>
<endpointBehaviors>
  <behavior name="endpointBehavior">
    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
  </behavior>
</endpointBehaviors>
</behaviors>


2. Update these values to maximum size in both Client and Server config.

XML
<binding name="tcpBinding" receiveTimeout="00:15:00" sendTimeout="00:15:00"  maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
          <security mode="None">
            <transport clientCredentialType="None" protectionLevel="None" />
            <message clientCredentialType="None" />
          </security>
        </binding>


a. maxReceivedMessageSize
b. maxBufferSize
c. maxBufferPoolSize

Thanks once again for the help.
 
Share this answer
 
Comments
nbabu20 2-Jan-14 14:34pm    
Solution 2 works perfectly. I had the same issue with NetTcp Service.
But i changed just on the server side, it started communicating.
Thanks for the solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900