如何使用 WCF 设置仅用于服务器回调的连接和仅用于客户端调用的连接?

发布于 2024-12-07 09:09:34 字数 535 浏览 1 评论 0原文

我想我没有说清楚。我的意思是如何使用 WCF 在与“客户端到服务器”连接不同的连接中设置回调(“服务器到客户端”)?

我总是看到仅使用一个 DuplexChannelFactory 的回调示例。这意味着仅使用一个 TCP 连接来进行客户端到服务器的调用并接收服务器到客户端的回调。

在我读完这个主题后,我想到了这个问题: 寻求 WCF 双工“TwoWay”订阅+回调示例

我是最佳答案,Ian林格罗斯说道:

我发现一些有助于避免死锁的规则。 (看看我的 WCF 问题就知道我的痛苦了!)

当来自同一客户端的调用正在进行时,服务器绝不能在同一连接上调用客户端。

和/或

在处理回调时,客户端绝不能在用于“回调”的同一连接上回调服务器。

我想知道如何使用 WCF 来实现它。

I don't think I was clear. What I meant was How to set a callback("server to client") in a different connection from a "client to server" connection using WCF ?

I always saw callbacks examples using just one DuplexChannelFactory. This implies using only one TCP connection to make client to server calls and receive server to client callbacks.

This question came to me after I read this this topic:
Seeking WCF Duplex "TwoWay" Subscribe+Callback Example

I the top answer, Ian Ringrose said:

Some rules I found to help avoid deadlocks. (Look at my WCF questions to see the pain I had!)

The sever must never call out to a client on the same connection as a call from the same client is in process on.

And/or

The client must never call back to the server on the same connection as is used for the “callbacks” while processing a call-back.

And I was wondering how to implement it using WCF.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

月下客 2024-12-14 09:09:34

使用 Double-Simplex WCF 的稳健的应用程序间通信上的此 CodeProject 准确回答了您的问题:

我决定运行两个单独的 WCF 连接(双单工)。每个应用程序将为传入消息运行 WCF 主机,每个应用程序将为传出消息运行 WCF 客户端。这是一个非常强大的解决方案,不会因停止和启动应用程序而被破坏。 WCF 客户端只需在需要时重新建立连接即可。

它的解决方式满足您从 Ian Ringrose 答案中提取的要求。

This CodeProject on Robust Interapplication Communications using Double-Simplex WCF answers exactly your question:

What I decided to do was run two separate WCF connections (double simplex). Each application would run a WCF Host for incoming messages and each application would run a WCF Client for outgoing messages. This is a pretty robust solution and will not be broken by stopping and starting the applications. The WCF Client simply re-establishes the connection if needed.

The way it is solved meets the requirements you have extracted from the Ian Ringrose answer.

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