远程主机使用WCF强制关闭现有连接

时间:2011-05-18 09:29:00

标签: wcf

我们有一个wcf pub / sub设置,通过netTcpBinding使用可靠的会话,并且在一台机器上,发布服务和订阅服务都托管在控制台应用程序中,我们得到了上述错误。这台机器在工作组中。我们部署机器的其他任何地方都在一个域中,它工作正常。我对wcf的了解有些局限,刚刚交给我,所以请耐心等待。有没有人对如何解决这个错误有任何建议?

完整的例外如下:

  

System.ServiceModel.CommunicationException   套接字连接已中止。这可能是由于处理消息的错误或远程主机超出接收超时或基础网络资源问题引起的。本地套接字超时为'10675199.02:48:05.4775807'   在System.ServiceModel.Channels.SocketConnection.EndRead()   在System.ServiceModel.Channels.DelegatingConnection.EndRead()   在System.ServiceModel.Channels.TracingConnection.EndRead()   在System.ServiceModel.Channels.ConnectionStream.ReadAsyncResult.HandleRead()   at System.ServiceModel.Channels.ConnectionStream.ReadAsyncResult.OnAsyncReadComplete(Object state)   在System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback()   在System.ServiceModel.Channels.SocketConnection.FinishRead()   在System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean hasResult,Int32 error,Int32 bytesRead)   在System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32错误,UInt32 bytesRead,NativeOverlapped * nativeOverlapped)   在System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode,UInt32 numBytes,NativeOverlapped * pOVERLAP)   内部例外:
  System.Net.Sockets.SocketException
  远程主机强制关闭现有连接   在System.ServiceModel.Channels.SocketConnection.EndRead()   在System.ServiceModel.Channels.DelegatingConnection.EndRead()   在System.ServiceModel.Channels.TracingConnection.EndRead()   在System.ServiceModel.Channels.ConnectionStream.ReadAsyncResult.HandleRead()   at System.ServiceModel.Channels.ConnectionStream.ReadAsyncResult.OnAsyncReadComplete(Object state)   在System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback()   在System.ServiceModel.Channels.SocketConnection.FinishRead()   在System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean hasResult,Int32 error,Int32 bytesRead)   在System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32错误,UInt32 bytesRead,NativeOverlapped * nativeOverlapped)   在System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode,UInt32 numBytes,NativeOverlapped * pOVERLAP)

我的绑定配置如下:

<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>

端点是:

<endpoint address="net.tcp://localhost:8000/SubscriptionService"
          binding="netTcpBinding" 
          bindingConfiguration="NetTcpBinding_ISubscriptionService" 
          contract="SubscriptionService.ISubscriptionService" 
          name="NetTcpBinding_ISubscriptionService" />

2 个答案:

答案 0 :(得分:3)

好的,我发现了我的问题。

客户端应用程序连接的服务的mxConnection为10.我们还使用了SecureMessaging,并且listenBacklog为1.修改后的maxConnections为100,listBacklog为200,一切正常。

答案 1 :(得分:2)

对我来说问题是我没有合适的服务参考(从开发机器到生产机器)。