我正在实现 WCF netTCPBinding 并在运行与数据库相关的任务时遇到问题。例外是“System.Net.Sockets.SocketException:'现有连接被远程主机强制关闭'在 net tcp 绑定中”。但是,行为是不可预测的,有时它不会给出异常并且运行平稳,有时它会给出异常。
我添加了服务限制,为读取器配额和缓冲区大小分配了最大值,但对我没有任何作用。但是,我无法将最大连接值从 10 增加到其他值,因为它给出了异常。我尝试了一切,但没有任何效果。
网络配置
<netTcpBinding>
<binding name="IOperationsCenterService_server_TCP" closeTimeout="01:03:00" openTimeout="01:03:00" receiveTimeout="01:10:00" sendTimeout="01:10:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="1000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="10:00:00" enabled="false" />
<security mode="None">
<!--<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />-->
</security>
</binding>
</netTcpBinding>
<behaviors>
<serviceBehaviors>
<behavior name="OpsCenter.ServiceApp.OperationsCenterServiceBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceThrottling maxConcurrentCalls="1000" maxConcurrentInstances="1000" maxConcurrentSessions="10000"/>
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<service behaviorConfiguration="OpsCenter.ServiceApp.OperationsCenterServiceBehavior" name="OpsCenter.ServiceApp.OperationsCenterService">
<identity>
<dns value="localhost" />
</identity>
<endpoint address="" binding="netTcpBinding" contract="OpsCenter.ServiceApp.IOperationsCenterService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
应用程序配置
<netTcpBinding>
<binding name="WSHttpBinding_IOperationsCenterService" closeTimeout="01:03:00" openTimeout="01:03:00" receiveTimeout="01:10:00" sendTimeout="01:10:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="1000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<reliableSession ordered="true" inactivityTimeout="10:00:00" enabled="false"/>
<security mode="None">
</security>
</binding>
</netTcpBinding>
请帮助我从星期一就被困在这里。
注 1: 该应用程序在 Visual Studio 调试模式下运行良好。但是,问题发生在发布模式或我在客户端计算机上安装应用程序时。