套接字连接被中止 - WCF
我有一个简单的客户端服务器应用程序,当我启动服务器并通过客户端发送消息时,它使用 WCF(netTcpBinding),一切正常,但是当我手动关闭服务器并再次打开它时(无需在以下位置关闭客户端应用程序)所有)下次客户端尝试向服务器发送消息时,我会收到此异常(在客户端):
套接字连接已中止。这可能是由于处理 y 时出错造成的 我们的消息或远程主机超出了接收超时,或者是一个underl ying网络资源问题。本地套接字超时为“00:00:59.9843903”。
如果我使用 basicHttpBinding 则不会出现问题。
有谁知道为什么会出现这个问题??? 谢谢, 丽然
I have a simple client server apps that uses WCF (netTcpBinding) when i'm launching the server and sending messages through the client everythings works fine , but when i'm closing the server manually and open it again (without closing the client app at all) the next time the client tries to send a message to the server i get this exception (on the client side):
The socket connection was aborted. This could be caused by an error processing y
our message or a receive timeout being exceeded by the remote host, or an underl
ying network resource issue. Local socket timeout was '00:00:59.9843903'.
if i use basicHttpBinding the problem doesn't occur.
is any one knows why this problem occurs ???
Thanks,
Liran
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是预期的行为。当您关闭服务器时,服务器上的 TCP 连接将关闭,您无法再从客户端调用它。再次启动服务器也无济于事。您必须捕获客户端上的异常,中止当前代理并创建并打开新代理。
使用BasicHttpBinding它可以工作,因为NetTcpBinding在代理的整个生命周期中使用单个通道(通道绑定到TCP连接),而BasicHttpBinding为每个调用创建一个新的通道(它重用现有的HTTP连接,或者如果连接不存在则创建新的通道)。
This is expected behavior. When you close the server, TCP connection on the server is closed and you can't call it from the client anymore. Starting the server again will not help. You have to catch the exception on the client, Abort current proxy and create and open new one.
With BasicHttpBinding it works because NetTcpBinding uses single channel for whole life of the proxy (the cannel is bound to TCP connection) whereas BasicHttpBinding creates new one for each call (it reuses existing HTTP connection or create new one if connection doesn't exist).