Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An existing connection was forcibly closed by the remote host with WCF

Tags:

wcf

We have a wcf pub/sub setup using reliable sessions via netTcpBinding and on one machine where both the publication service and subscription service are being hosted in a console applications we get the above error. This machine is in a workgroup. Everywhere else we have deployed the machine is in a domain and it works fine. My knowledge of wcf is somewhat limited and this has just been handed to me so please be patient. Does anyone have any advice on how to resolve this error?

The full exception is below:

System.ServiceModel.CommunicationException 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 '10675199.02:48:05.4775807'.
at System.ServiceModel.Channels.SocketConnection.EndRead() at System.ServiceModel.Channels.DelegatingConnection.EndRead() at System.ServiceModel.Channels.TracingConnection.EndRead() at System.ServiceModel.Channels.ConnectionStream.ReadAsyncResult.HandleRead() at System.ServiceModel.Channels.ConnectionStream.ReadAsyncResult.OnAsyncReadComplete(Object state) at System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback() at System.ServiceModel.Channels.SocketConnection.FinishRead() at System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean haveResult, Int32 error, Int32 bytesRead) at System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped) at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP) Inner exception:
System.Net.Sockets.SocketException
An existing connection was forcibly closed by the remote host
at System.ServiceModel.Channels.SocketConnection.EndRead() at System.ServiceModel.Channels.DelegatingConnection.EndRead() at System.ServiceModel.Channels.TracingConnection.EndRead() at System.ServiceModel.Channels.ConnectionStream.ReadAsyncResult.HandleRead() at System.ServiceModel.Channels.ConnectionStream.ReadAsyncResult.OnAsyncReadComplete(Object state) at System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback() at System.ServiceModel.Channels.SocketConnection.FinishRead() at System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean haveResult, Int32 error, Int32 bytesRead) at System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped) at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

My binding configuration is as follows:

<netTcpBinding>
    <binding name="NetTcpBinding_ISubscriptionService"
             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="524288"
                      maxBytesPerRead="4096"
                      maxNameTableCharCount="16384" />
        <reliableSession ordered="true"
                         inactivityTimeout="00:10:00"
                         enabled="true"/>
        <security mode="Transport"
                  transport=""
                  clientCredentialType="Windows"
                  protectionLevel="EncryptAndSign"
                  message=""/>
    </binding>
</netTcpBinding>

The Endpoint is:

<endpoint address="net.tcp://localhost:8000/SubscriptionService"
          binding="netTcpBinding" 
          bindingConfiguration="NetTcpBinding_ISubscriptionService" 
          contract="SubscriptionService.ISubscriptionService" 
          name="NetTcpBinding_ISubscriptionService" />
like image 867
John Avatar asked May 18 '11 09:05

John


1 Answers

Ok, I found out what my problem was.

The service the client application was connecting to had mxConnection of 10. We were also using SecureMessaging and had a listenBacklog of 1. Amended maxConnections to 100 and listBacklog to 200 and it all works fine.

like image 138
John Avatar answered Sep 28 '22 12:09

John