TCP错误代码10060:连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败

本文关键字:连接 失败 响应 建立 或者 10060 错误代码 TCP 因为 一段时间 | 更新日期: 2023-09-27 18:26:53

我们有一个Framework 4.x WCF服务,它又使用Net.Tcp绑定托管在Windows服务中。从客户端计算机调用WCF服务时,请正确运行。如果我们打开Window防火墙,那么它会将错误显示为

****"Error 10060 - Could not connect to net.tcp://1xx.xxx.xxx.xxx:9098/MyService/. 
The connection attemp lasted for a time span of 00:00:21. TCP error code 10060: A connection attemp failed because the connection party didnot properly respnod after a period of time, or established connection failed because connected host has failed to respond 19x.xxx.xxx.xxx:9098."****

我在承载WCF服务的计算机上打开了具有入站和出站规则的端口9098。并从客户端机器打开808端口。我们仍然会遇到这个错误。

TCP错误代码10060:连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败

也面临同样的问题

以下配置保存了我的一天

现在它没有说时间,直到5分钟

服务器端

<system.serviceModel>
<diagnostics>
  <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
  <netTcpBinding>
    <binding name="meritBasicBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
             closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:05:00" receiveTimeout="00:05:00">
      <readerQuotas maxDepth="128" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
      <reliableSession ordered="true" inactivityTimeout="00:05:00" enabled="false"/>
      <security mode="Transport">
        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
      </security>
    </binding>
  </netTcpBinding>
</bindings>
<services>
  <service name="Merit.Services.Reporting" behaviorConfiguration="mexBehaviour">
    <endpoint address="Reporting" binding="netTcpBinding" behaviorConfiguration="meritEndPointBehaviour" bindingConfiguration="meritBasicBinding" contract="Merit.Services.IReporting"></endpoint>        
    <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"></endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://Localhost:8090/"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="mexBehaviour">
      <serviceMetadata httpGetEnabled="false"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="meritEndPointBehaviour">
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
  </endpointBehaviors>
</behaviors>

客户端

<system.serviceModel>
<bindings>
  <netTcpBinding>
    <binding name="meritBasicBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" listenBacklog="2147483647"
             closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:05:00" receiveTimeout="00:05:00">
      <readerQuotas maxDepth="128" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
      <security mode="Transport">
        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
      </security>
    </binding>
  </netTcpBinding>
</bindings>
<client>
  <endpoint address="net.tcp://Localhost:8090/Reporting" binding="netTcpBinding"
    bindingConfiguration="meritBasicBinding" behaviorConfiguration="meritEndPointBehaviour" contract="MeritReportingService.IReporting"
    name="NetTcpBinding_IReporting">
    <identity>
      <servicePrincipalName value="host/SERVER DOMAIN ADDRESS(usually picked automatically)" />
    </identity>
  </endpoint>
</client>
<behaviors>
  <endpointBehaviors>
    <behavior name="meritEndPointBehaviour">
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
  </endpointBehaviors>
</behaviors>