WCF EndpointNotFoundException比TimeoutException花费更长的时间

时间:2014-05-02 20:21:52

标签: c# wcf timeoutexception endpointnotfoundexception

我设置了一组服务,每个服务彼此交谈;如果我" A"以及下面的约束我会假设发送消息给" B"(活着)和" C"(不活着)B将返回,如果处理没有花费比sendTimeout更长的时间,否则它将是TimeoutException。在" 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>

1 个答案:

答案 0 :(得分:1)

我不是百分百肯定,但你可能会碰到这样一个事实:当WCF客户端执行时,操作系统用来解析IP地址的时间不计入SendTimeout设置。您可以在此处查看更多详细信息:WCF Not Timing out correctly?