1

我设置了一组相互通信的服务;使用以下绑定,我会假设如果我“A”向“B”(活着)和“C”(不活着)发送一条消息,如果处理时间不超过定义的 sendTimeout,B 将返回,否则它将是超时异常。在“C”失败且不可用的情况下,我会假设它也会在 sendTimeout 定义的时间内返回。对于“B”,这似乎是正确的,但对于“C”,会捕获一个 EndpointNotFoundException,但它需要的时间比为 sendTimeout 定义的 5 秒长得多。我的配置中是否缺少某些内容。服务和客户端使用相同的绑定

<bindings>
  <netTcpBinding>
    <binding name="SSS" maxBufferPoolSize="524288" maxBufferSize="134217728" maxReceivedMessageSize="134217728" receiveTimeout="infinite" sendTimeout="00:00:05" portSharingEnabled="true">
      <readerQuotas
         maxDepth="32"
         maxStringContentLength="65535"
         maxArrayLength="16384"
         maxBytesPerRead="4096"
         maxNameTableCharCount="16384" />
      <security mode="None">
        <transport clientCredentialType="None" protectionLevel="None"/>
        <message clientCredentialType="None"/>
      </security>
      <reliableSession ordered="true"/>
    </binding>
  </netTcpBinding>
</bindings>


<service behaviorConfiguration="DefaultBehavior" name="hostObj"> 
    <endpoint binding="netTcpBinding" bindingConfiguration="SSS" contract="Contract.IHost" />
  </service>


<endpoint name="serverAppHostEndpoint" binding="netTcpBinding" bindingConfiguration="SSS" contract="Contract.IHost" />


<behaviors>
  <serviceBehaviors>
    <behavior name="DefaultBehavior">
      <!-- To avoid disclosing metadata information, 
      set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="False" />
      <!-- To receive exception details in faults for debugging purposes, 
      set the value below to true.  Set to false before deployment 
      to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
4

1 回答 1

1

我不确定 100%,但您可能会遇到这样一个事实,即当 WCF 客户端执行时,操作系统用于解析 IP 地址的时间不计入 SendTimeout 设置。您可以在此处查看更多详细信息:WCF 未正确超时?

于 2015-03-21T18:41:53.597 回答