我有一个网站,它连接到在负载均衡器和防火墙后面的两个应用程序服务器上部署在 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 连接,这很好。
如果我需要任何其他信息,请告诉我。非常感谢任何指导,因为我在这方面花了很多时间。
配置文件的片段如下:
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>