使用TCP时发生WCF错误

使用TCP时发生WCF错误,wcf,tcp,communication,runtime-error,Wcf,Tcp,Communication,Runtime Error,我有一个网站,它连接到部署在IIS中的WCF服务,该服务位于负载平衡器和防火墙后面的两个应用服务器上。当我使用HTTP端点时,网站能够成功连接到WCF服务。然而,在切换到TCP协议时,我看到了以下错误 预计会有更多数据,但已达到EOF [InvalidDataException:需要更多数据,但已达到EOF。] [ProtocolException:读取流位置0处的消息帧格式时出错(状态:ReadingUpgradeRecord)] [ProtocolException:网络上的服务器。tcp:

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

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

[InvalidDataException:需要更多数据,但已达到EOF。]

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

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

网站应用程序池在本地用户帐户下运行,而WCF服务在默认ApplicationPoolIdentity下运行。在服务端未生成任何跟踪日志。在客户端生成跟踪日志时出现了相同的错误

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

我已经验证了从web服务器到应用程序服务器的TCP连接,一切正常

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

配置文件中的代码段如下所示:

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服务配置问题


在尝试调试WCF配置之前,请尝试从图片中删除负载平衡器(如果可以),并直接点击WCF服务。默认情况下,大多数负载平衡器将支持HTTP;但是对于任何其他协议都需要特殊配置。

谢谢您的建议。通过基础架构团队验证,负载平衡器TCP配置似乎存在问题。修复后将再次检查。