【问题标题】:NettcpBinding wcf - how to improve the time of detect faultedNettcpBinding wcf - 如何提高检测故障的时间
【发布时间】:2016-02-07 16:50:17
【问题描述】:

我有一个应用程序连接到 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秒..

我该如何改进?

【问题讨论】:

    标签: wcf nettcpbinding net-tcp


    【解决方案1】:

    我没有看到您为绑定设置了receiveTimeout。根据我的经验,这是最重要的之一。 也将其设置为 5 秒。

    sendTimeout 是关于等待消息发送的时间。所以,除非你发送任何东西(调用一个方法),否则没有什么可以监控的。 receiveTimeout 正好相反——要等多久才能放弃。

    【讨论】:

    • 谢谢,我在客户端和服务器中都设置了 receiveTimeout="00:00:05"、sendTimeout="00:00:05" 和 inactivityTimeout="00:00:05",即改进。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-02
    • 1970-01-01
    • 2019-09-11
    • 2012-12-05
    • 1970-01-01
    • 1970-01-01
    • 2018-01-23
    相关资源
    最近更新 更多