WCF - 如果在客户端连接时关闭,则关闭双工 ServiceHost 会阻塞 CloseTimeout 持续时间

发布于 2024-08-09 12:07:01 字数 498 浏览 2 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不顾 2024-08-16 12:07:01

也许,最好的方法是通知客户端(你有双工,所以你可以)并让客户端关闭通道。

Probably, the best way is to notify client (you have duplex, so you can) and let client close the channel.

游魂 2024-08-16 12:07:01

“理想情况下,客户会立即收到通道出现故障的通知,以便用户可以立即看到更新已停止。”

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:

  • Closed
  • Closing
  • Faulted
  • Opened
  • Opening.

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文