我创建了2个WCF endpoints ,服务 endpoints 驻留在桌面应用程序上(IP地址为10.8.20.175);客户端 endpoints 驻留在Web托管的应用程序上 .
这是服务 endpoints 配置
<services>
<service behaviorConfiguration="NotificationServiceBehavior"
name="NotificationService">
<endpoint address="" binding="netTcpBinding" contract="INotificationService" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:3337/NotificationService" />
</baseAddresses>
</host>
</service>
</services>
这是客户端 endpoints 配置
<system.serviceModel>
<client>
<endpoint address="net.tcp://10.8.20.175:3337/NotificationService"
binding="netTcpBinding" contract="INotificationService"
name="NetTcpBinding_INotificationService" />
</client>
<bindings>
<netTcpBinding>
<binding sendTimeout="00:10:00" maxReceivedMessageSize="1000000" name="NetTcpBinding_INotificationService"/>
</netTcpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
请注意,在 endpoints 地址中,我输入了服务 endpoints 的实际IP地址 . 当我在localhost上测试服务 endpoints 和客户端 endpoints 之间的通信时,该地址是localhost:3337并且通信良好 . 现在,当我部署 endpoints 时,我收到以下错误:
套接字连接已中止 . 这可能是由于处理消息的错误或远程主机超出接收超时或基础网络资源问题引起的 . 本地套接字超时为'00:10:00' .
System.Net.Sockets.SocketException:System.ServiceModel.Channels处的System.Net.Sockets.Socket.Receive(Byte []缓冲区,Int32偏移量,Int32大小,SocketFlags socketFlags)上的远程主机强制关闭现有连接 . SocketConnection.ReadCore(Byte []缓冲区,Int32偏移量,Int32大小,TimeSpan超时,布尔结束)
日志表明连接被远程主机强制关闭,这意味着客户端 endpoints 实际发送了请求并且它到达了服务 endpoints ?我在这一点上很困惑 . 我不确定客户端 endpoints 是否可以到达服务 endpoints .
顺便说一句,从客户端 endpoints 机器,我可以ping服务 endpoints 的机器,也可以在端口3337上telnet到远程机器 .
1 回答
根据我的经验,这表明客户已达到您的服务并已激活 . 但是在通话过程中发生了一些事情,导致服务的回复失效 .
最好的检查方法是打开WCF tracing为您的服务 . 这应该有助于您更好地了解服务器端发生的情况 .