【问题标题】:WCF Custom binding - send timeout always reachedWCF 自定义绑定 - 始终达到发送超时
【发布时间】:2009-02-17 07:13:41
【问题描述】:

我有一个需要实现回调并托管在 IIS 6.0 上的 wcf 服务。由于 IIS 6.0 不支持 net.tcp 绑定,我决定使用自定义绑定,因为该服务由不同时区的不同客户端访问,并且使用自定义绑定,我可以将允许的时钟偏移时间设置为除默认一个。

这是我的服务器配置文件:

<bindings>
  <customBinding>        
    <binding name="pscNetBinding" openTimeout="00:10:00">          
      <reliableSession acknowledgementInterval="00:00:00.2000000"
  flowControlEnabled="true" inactivityTimeout="23:59:59"
  maxPendingChannels="128" maxRetryCount="8" maxTransferWindowSize="128"
  ordered="true" />
      <compositeDuplex />
      <oneWay maxAcceptedChannels="128" packetRoutable="false">
        <channelPoolSettings idleTimeout="00:10:00"
  leaseTimeout="00:10:00" maxOutboundChannelsPerEndpoint="10" />
      </oneWay>
      <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
  messageVersion="Default" writeEncoding="utf-8">
        <readerQuotas maxDepth="2147483647"
  maxStringContentLength="2147483647" maxArrayLength="2147483647"
  maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      </textMessageEncoding>
      <httpTransport manualAddressing="false"
  maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
  allowCookies="false" authenticationScheme="Anonymous"
  bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
  keepAliveEnabled="true" maxBufferSize="2147483647"
  proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered"
  unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true"/>
    </binding>
  </customBinding>
</bindings>

<services>
  <service name="SchneiderElectric.PSCNet.Server.Services.PSCNetWCFService" behaviorConfiguration="Behaviors1">
    <host>
      <baseAddresses>
        <add baseAddress ="http://10.155.18.18:2000/PSCNet"/>
      </baseAddresses>
    </host>
    <endpoint address="" binding="customBinding"    bindingConfiguration="pscNetBinding"
                                contract="SchneiderElectric.PSCNet.Server.Contracts.IPSCNetWCFService"/>
  </service>
</services>    
<behaviors>
  <serviceBehaviors>
    <behavior name="Behaviors1">
      <serviceMetadata httpGetEnabled = "true"/>
      <!--<serviceThrottling maxConcurrentCalls="2048" maxConcurrentSessions="2048" maxConcurrentInstances="2048" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />-->
    </behavior>
  </serviceBehaviors>
</behaviors>

客户端配置文件:

  <bindings>
    <customBinding>
      <binding name="pscNetBinding" openTimeout="00:10:00">            
        <reliableSession acknowledgementInterval="00:00:00.2000000"
    flowControlEnabled="true" inactivityTimeout="23:59:59"
    maxPendingChannels="128" maxRetryCount="8" maxTransferWindowSize="128"
    ordered="true" />
        <compositeDuplex />
        <oneWay maxAcceptedChannels="128" packetRoutable="false">
          <channelPoolSettings idleTimeout="00:10:00"
    leaseTimeout="00:10:00" maxOutboundChannelsPerEndpoint="10" />
        </oneWay>
        <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
    messageVersion="Default" writeEncoding="utf-8" >
          <readerQuotas maxDepth="2147483647"
    maxStringContentLength="2147483647" maxArrayLength="2147483647"
    maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </textMessageEncoding >
        <httpTransport manualAddressing="false"
    maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
    allowCookies="false" authenticationScheme="Anonymous"
    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
    keepAliveEnabled="true" maxBufferSize="2147483647"
    proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered"
    unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" />                    
      </binding>
    </customBinding>
  </bindings>
  <client>
    <endpoint address="http://10.155.18.18:2000/PSCNet" binding="customBinding"
        bindingConfiguration="pscNetBinding" contract="PSCNetWCFService.IPSCNetWCFService"
        name="pscNetBinding" />
  </client>

如果我在同一台机器上使用服务器和客户端,一切正常。如果我在不同的机器上运行它们,我会收到以下错误:

无法连接到 http://10.155.18.198:9000/e60ba5b3-f979-4922-b9f8-c820caaa04c2。 TCP 错误代码 10060:连接尝试失败,因为已连接 当事人在一段时间后没有正确回应,或建立 连接失败,因为连接的主机没有响应 10.155.18.198:9000.

社区中的任何人都可以在这方面帮助我吗?

【问题讨论】:

    标签: wcf binding wcf-security


    【解决方案1】:

    您能否展示定义customBinding 的配置部分?也许您只是没有粘贴该部分,但是当您定义自定义绑定时,您必须至少指定编码和传输 - 如下所示:

    <bindings>
        <customBinding>
            <binding name="MyCustomTextTcpBinding">
                <textMessageEncoding />
                <tcpTransport />
            </binding>
        </customBinding>
    </bindings>
    

    您还可以粘贴您定义“pscNetBinding”绑定配置的部分吗?

    【讨论】:

    • 感谢您的回复,我已将绑定更改为 net.tcp 绑定,一切正常。我打算在寡妇服务上托管它。如果我的服务仅用于登录验证和服务中的 Autocad 生成,您认为托管在 windows 服务上是否很好。
    • 是的,我认为 Windows 服务会很好。如果您有 IIS 6.0,那么无论如何您都不能真正托管 nettcp 服务。在 IIS 7 中,您可以使用 WAS 托管 nettcp,但如果是我,我只会做一个 windows 服务。这是一篇好文章:msdn.microsoft.com/en-us/library/ms730158.aspx
    • 感谢您的文章,我只是想通过在 Windows 服务上托管来确定我所做的事情是正确的。既然是部署在生产服务器,你觉得使用windows服务有什么缺点吗?
    • 我们将许多 WCF 服务托管为 Windows 服务。它对我们来说运行良好,尤其是对于非 HTTP 服务。
    【解决方案2】:

    Windows 服务无疑是一个不错的解决方案,但我认为更好的是自托管 并且您可以对其进行任何类型的绑定。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-05
      • 2010-11-29
      相关资源
      最近更新 更多