WCF - 如果在客户端连接时关闭,则关闭双工 ServiceHost 会阻塞 CloseTimeout 持续时间
我有一个 Windows 服务,托管三个不同的双工 WCF 通道。客户可以连接以通过回调合约向他们发送更新。本质上存在三个发布-订阅渠道。
当客户端连接时,该服务需要很长时间才能反弹。调用 ServiceHost.Close
需要 10 秒才能返回(因此服务需要 30 秒以上才能停止。) 结果我的配置中的 closeTimeout
是 10 秒。更改此值表明这是问题的原因。
我需要做什么才能立即关闭频道?我不喜欢某些事情超时的想法。我可以调用Abort
,但似乎必须有更好的方法。我以前没有在非双工通道上看到过这种情况,所以假设这与双工有关。
理想情况下,客户端会立即收到通道出现故障的通知,以便用户可以立即看到更新已停止。
I have a Windows Service that hosts three different duplex WCF channels. Clients can connect to have updates sent to them via their callback contract. Essentially there are three pub-sub channels.
This service takes a long time to bounce when clients are connected. The call to ServiceHost.Close
takes 10 seconds to return (so the service takes 30+ seconds to stop.) It turns out that my closeTimeout
in config is 10 seconds. Changing this value indicates that this is the cause of the problem.
What do I have to do to close the channel promptly? I don't like the idea that something is timing out. I could call Abort
, but it seems that there must be a better way. I haven't seen this on non-duplex channels before, so assume it's something to do with it being duplex.
Ideally the client would be notified immediately that the channel had faulted, so that the user could see straight away that updates have halted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许,最好的方法是通知客户端(你有双工,所以你可以)并让客户端关闭通道。
Probably, the best way is to notify client (you have duplex, so you can) and let client close the channel.
“理想情况下,客户会立即收到通道出现故障的通知,以便用户可以立即看到更新已停止。”
WCF 客户端实例具有您可以订阅的事件:
一旦您的双工通道因任何原因停止,就会引发故障事件。
我想知道为什么你的服务主机需要 30 秒以上才能关闭。你能提供一些示例代码吗?
"Ideally the client would be notified immediately that the channel had faulted, so that the user could see straight away that updates have halted."
The WCF client instance has events you can subscribe to:
The Faulted event is raised as soon as your duplex channel halted from any reason.
I wonder why is your is your service host taking 30+ seconds to close. Can you provide some sample code?