【问题标题】:WCF Error with TCPTCP 的 WCF 错误
【发布时间】:2013-01-30 04:21:26
【问题描述】:

我有一个网站连接到部署在 IIS 中的 WCF 服务,该服务位于负载平衡器和防火墙后面的两台应用服务器上。当我使用 HTTP 端点时,网站能够成功连接到 WCF 服务。但是在切换到 TCP 协议时,我看到了以下错误。

预计会有更多数据,但已达到 EOF。

[InvalidDataException: 应有更多数据,但已达到 EOF。]

[ProtocolException: 在流的位置 0 读取消息帧格式时出错(状态:ReadingUpgradeRecord)]

[ProtocolException:net.tcp:///SecurityService.svc 处的服务器拒绝了会话建立请求。]

网站应用程序池在本地用户帐户下运行,而 WCF 服务在默认 ApplicationPoolIdentity 下运行。服务端没有生成跟踪日志。跟踪日志在客户端生成同样的错误。

WCF 服务托管在应用程序服务器的默认端口 808 下,但它不被任何其他应用程序/服务共享。 环境:Win2k8,IIS 7.5

我已经验证了从 Web 服务器到应用程序服务器的 TCP 连接,没有问题。

如果我需要任何其他信息,请告诉我。非常感谢任何指导,因为我在这方面花了很多时间。

配置文件中的 sn-p 如下:

WCF 服务

<bindings>
      <netTcpBinding>
        <binding name="NetTcpBinding_Configuration" closeTimeout="00:10:00"
          openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
          transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
          hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288"
          maxBufferSize="2147483647" maxConnections="100" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="None"/>
        </binding>
      </netTcpBinding>
    </bindings>
<services>
      <service name="<namespace>.ServiceImplementation.Security">
        <endpoint address="net.tcp://<servername>/SecurityService.svc"
          binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Configuration"
          contract="<namespace>.ServiceInterface.ServiceContracts.ISecurity" name="NetTcpBinding_Security">
          <identity>
            <servicePrincipalName value="host/<servername>" />
          </identity>
        </endpoint>
      </service>
    </services>

网站客户端

<bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_Configuration" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
      <netTcpBinding>
        <binding name="NetTcpBinding_Configuration" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
<client>
      <endpoint address="http://<servername>/SecurityService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Configuration" contract="SecurityService.Security" name="BasicHttpBinding_Security" />
      <endpoint address="net.tcp://<servername>/SecurityService.svc" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Configuration" contract="SecurityService.Security" name="NetTcpBinding_Security">
        <identity>
          <servicePrincipalName value="host/<servername>" />
        </identity>
      </endpoint>
    </client>

【问题讨论】:

    标签: wcf tcp communication runtime-error


    【解决方案1】:

    如果我是你,我会Wireshark 从客户端到服务器的流量。您只是想确保您的流量不会在沿途某处被阻塞。如果您可以确认不是这种情况,那么它一定是 WCF 服务配置问题。

    在尝试调试 WCF 配置之前,请尝试从图片中移除负载均衡器(如果可以),然后直接点击 WCF 服务。大多数负载均衡器将默认支持 HTTP;但需要对任何其他协议进行特殊配置。

    【讨论】:

    • 感谢您的建议。经基础设施团队验证,负载平衡器 TCP 配置似乎存在问题。修复后会再次检查。
    猜你喜欢
    • 2014-01-31
    • 1970-01-01
    • 1970-01-01
    • 2011-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-15
    • 1970-01-01
    相关资源
    最近更新 更多