TCP错误代码10060:连接尝试失败bcos连接方在一段时间后没有正确重新启动,或建立连接失败

时间:2014-10-16 09:05:41

标签: c# .net wcf tcp

我们有一个Framework 4.x WCF服务,它依次使用Net.Tcp Binding托管在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端口。我们仍然会收到此错误。

1 个答案:

答案 0 :(得分:0)

面临同样的问题

以下配置保存了我的一天

现在它没有说超时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>