Search code examples
wcfnettcpbindingnet-tcp

NettcpBinding wcf - how to improve the time of detect faulted


I have an application that is connect to wcf server for getting time async.

It's for keep connection alive by tcp.

So i want to detact that i disconnected from the server so i register to event faulted.

so far all good, but i find that the detection of disconnected is alwasy more than or equals to 20 deconds and i want to improve that, i think maybe by change settings of nettcp as follow i have right now:

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

I change to that:

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

but it seems that still more than or equal to 20 seconds..

How to can i to improve?


Solution

  • I don't see that you set receiveTimeout for the binding. In my experience this is one of the most important ones. Set it to 5 seconds as well.

    sendTimeout is about how long to wait until message is sent. So, unless you send anything (call a method) there is nothing to monitor. receiveTimeout is the opposite - for how long to wait before giving up.