如何查明我的 WCF 服务器何时退出(并关闭它的 TCP 连接)
我正在使用 nettcpbinding 绑定(目前具有可靠的消息传递)。
当服务器执行 serviceHost.Close() 时,TCP 连接应该完全关闭,因此应该通知客户端。 如何使用 WCF 挂钩此事件?(请注意,这与因网络问题而关闭的 TCP 连接不同,此时可靠的消息传递可能能够重新创建连接)
如果服务器调用 serviceHost .Abort() ,那么客户端将永远无法向其发送另一条消息,因此我希望在所有重试超时后会引发一些事件。
(IChannel.Faulted 和 IChannel.Closing 事件不会在客户端触发)
I am using the nettcpbinding binding (with reliably messaging at present).
When the server does a serviceHost.Close(), the TCP connection should be cleanly closed and therefore the client side should be told. How do I hook this event with WCF? (Note this is not the same as the TCP connection being closed by a network problem, when reliably messaging may be able to recreate the connection)
If the server calls serviceHost.Abort() , then the client will never be able to send it another message, so I would expect some event to be raised after all the retry timeouts.
(The IChannel.Faulted and IChannel.Closing events do not get fired on the client side)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来WCF并没有公开很多TCP可以做的事情,因为它认为HTTP是世界的中心。
It seems that WCF does not expose a lot of what TCP can do, as it thinks that HTTP is the centre of the world.
不完全是您正在寻找的内容,但可以选择将您的服务配置为 双工服务并在关闭服务主机之前向客户端发送终止通知。
Not exactly what you are looking for, but an option wpuld be to configure your service as a duplex service and send a termination notification to clients before closing the service host.