【问题标题】:An existing connection was forcibly closed by the remote host with WCF远程主机使用 WCF 强制关闭现有连接
【发布时间】:2011-05-18 09:29:00
【问题描述】:

我们通过 netTcpBinding 使用可靠会话进行 wcf 发布/订阅设置,并且在发布服务和订阅服务都托管在控制台应用程序中的一台机器上,我们收到上述错误。这台机器在一个工作组中。我们部署机器的其他任何地方都在域中,并且工作正常。我对 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() 在 System.ServiceModel.Channels.ConnectionStream.ReadAsyncResult.OnAsyncReadComplete(对象状态) 在 System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback() 在 System.ServiceModel.Channels.SocketConnection.FinishRead() 在 System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(布尔 hasResult,Int32 错误,Int32 bytesRead) 在 System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 错误,UInt32 字节读取,NativeOverlapped* nativeOverlapped) 在 System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 错误代码,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() 在 System.ServiceModel.Channels.ConnectionStream.ReadAsyncResult.OnAsyncReadComplete(对象状态) 在 System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback() 在 System.ServiceModel.Channels.SocketConnection.FinishRead() 在 System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(布尔 hasResult,Int32 错误,Int32 bytesRead) 在 System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 错误,UInt32 字节读取,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" />

【问题讨论】:

标签: wcf


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    对我来说,问题是我没有正确的服务参考(来自开发机器与生产机器)。

    【讨论】:

    • 我也是。尴尬吧? :)
    猜你喜欢
    • 2011-11-04
    • 2011-01-06
    • 2013-08-08
    • 1970-01-01
    • 1970-01-01
    • 2020-11-30
    • 2019-01-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多