双工 WCF 服务通道持续活动 (WSDualHttpBinding)
架构:
- 包含 wcf 双工服务的控制台应用程序;
- Windows 应用程序消费者;每个应用程序都订阅 Duplex,因此我们有一个订阅者列表 如果发生某些事件,服务必须向其中一些人发送通知;
问题:
- 如何持续保持连接活动,以便服务可以向客户端发送通知?
我发现这个绑定有2个通道。我需要永久打开服务通道(用于回调)。
谢谢;
The arhitecture:
- console application that contains a wcf duplex service;
- windows app consumers; every app subscribe to Duplex, so we have a list of subscribers
and the service must send notifications to some of them in case that some events apper;
The problem:
- how to maintain the connection alive continuously so that the service can send notifications to clients ?
I found that there are 2 channels for this binding. I need to have permanently the channel from service (for callbacks) open.
Thanks;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了和你一样的问题,要解决它,你需要实现一个保持活动的方法。对服务进行虚拟调用对于拥有 24/7 WCF 服务来说有点愚蠢,因为这并不是 WCF 的最佳架构方式,但我们知道有时我们需要的并不总是最好的。
是的,只需每 5 分钟调用一次 WCF 服务即可保持连接处于活动状态。也许您还会遇到其他问题,就我而言,我没有很多 WCF 服务的订阅者,所以这个解决方案很好。
I had the same problem than you, to solve it you need to implement a keep alive method. A dummy call to your service is kind of stupid to have a 24/7 WCF service because is not really the best architecture way of WCF but we know sometimes what we need is not always the best thing.
So yep, just implement a call to the WCF service every 5 minutes and by doing that you keep alive the connection. Maybe you can have others problems too, in my case I don't have a lot of subscribers of the WCF service so this solution was fine.
只要客户端连接到服务,回调通道就会处于活动状态。一旦客户端断开连接(或者通道出现故障),回调通道将关闭。
As long as a client is connected to the service, the callback channel will be alive. Once the client disconnects (or the channel gets faulted), the callback channel will close.