WCF 服务 - 处理行为不良的客户端?

发布于 2024-12-20 19:55:13 字数 580 浏览 0 评论 0原文

我们的 WCF 解决方案中有一个自定义侦听器,它继承自 ChannelListenerBase

我们有一个行为恶劣的客户端(超出我们的控制范围),它与我们进行 TCP 对话,内容如下:

SYN  
SYN,ACK  
RST  

基本上,他们试图在套接字建立、失败和关闭套接字之前对其执行操作。

在我们的 OnEndAcceptChannel 代码中,我们最终无法创建通道,因为当我们到达那里时,底层 Socket 已经关闭,并且我们得到了 SocketException。这似乎杀死了监听器,阻止它接受进一步的连接。

OnEndAcceptChannel 开始,我们尝试返回 null、抛出异常以及对侦听器进行故障处理,以便可以在调用堆栈的更高层重新启动它。后者是我们发现的唯一允许通道有效地继续侦听的解决方案,但这具有终止所有已建立的服务连接的令人不快(且不可接受)的副作用。

有人对如何处理这种情况有任何建议,继续倾听,并且不失去已建立的连接......?

We have a custom listener on our WCF solution, which inherits from ChannelListenerBase<IDuplexSessionChannel>.

We have a badly-behaved client (out of our control), which has a TCP conversation with us along the following lines:

SYN  
SYN,ACK  
RST  

Basically, they're trying to perform operations on the socket before it's established, failing, and closing the socket.

In our OnEndAcceptChannel code, we end up not being able to create a channel, because the underlying Socket has already been closed by the time we get there, and we get a SocketException. This then seems to kill the listener dead, stopping it accepting further connections.

From OnEndAcceptChannel, we've tried returning null, throwing the Exception, and Faulting the listener so that it can be restarted higher up the call stack. The latter is the only solution we've found that will allow the channel to effectively keep on listening, but that has the unpleasant (& unacceptable) side effect of killing all established connections to the service.

Anybody got any suggestions of how to handle this situation, keep listening, and not lose established connections...?

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

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

发布评论

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

评论(1

故人如初 2024-12-27 19:55:13

我们最终成功解决了这个问题。我们没有返回 null,而是返回了一个实现 IDuplexSessionChannel 的虚拟类的实例,该类本质上是一个哑状态机,仅此而已 - 愚弄 WCF 继续执行。

We managed to fix it in the end. Instead of returning null, we returned an instance of a dummy class implementing IDuplexSessionChannel that is essentially a dumb state machine, and nothing more - fools WCF into carrying on regardless.

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