我有一个连接到 wcf 服务器以获取时间异步的应用程序。
它用于通过 tcp 保持连接。
所以我想知道我与服务器断开连接,所以我注册到事件故障。
到目前为止一切都很好,但我发现断开连接的检测总是大于或等于 20 个 deconds,我想改进它,我想也许可以通过改变 nettcp 的设置,如下所示:
<netTcpBinding>
<binding name="NetTcpBindingConf" closeTimeout="00:00:05" openTimeout="00:00:05" sendTimeout="00:00:10" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="100" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="20" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="5048576" maxArrayLength="50000" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:04:00" enabled="true"/>
<security mode="Transport">
<transport clientCredentialType="None" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
我改为:
<netTcpBinding>
<binding name="NetTcpBindingConf" closeTimeout="00:00:05" openTimeout="00:00:05" sendTimeout="00:00:05" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="100" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="20" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="5048576" maxArrayLength="50000" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:00:05" enabled="true"/>
<security mode="Transport">
<transport clientCredentialType="None" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
但似乎仍然大于或等于20秒..
我该如何改进?