奇怪的 WCF net.tcp 异常

发布于 2024-09-17 13:37:57 字数 857 浏览 10 评论 0原文

我有一个带有 net.tcp 传输的 WCF 客户端/服务。当我在客户端打开 WCF 跟踪时,我在跟踪中看到以下错误(请参阅服务跟踪查看器的屏幕截图)。奇怪的是,WCF 正在处理和恢复此错误,而我的客户端没有收到任何异常并且它继续工作。此异常经常、随机发生,但并非在每个 Web 方法调用中都发生。 客户端(Windows XP)身份验证是 Windows,服务由 SPN 标识,服务在 NLB(Windows Server 2003)后面的 Windows 服务上自托管。 谁能解释一下这里发生了什么。

跟踪 xml 中的异常堆栈跟踪为:

<ExceptionString>
System.ServiceModel.Security.MessageSecurityException: The server rejected the upgrade request. ---&gt; System.ServiceModel.ProtocolException: Error while reading message framing format at position 0 of stream (state: ReadingUpgradeRecord) ---&gt; System.IO.InvalidDataException: More data was expected, but EOF was reached.
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
</ExceptionString>

Screenshot

I have a WCF client/service with net.tcp transport. When I turn on the WCF tracing on client side I am seeing the following errors in trace (see screenshot from service trace viewer). The strange thing is that WCF is handling and recovering this error and my client doesn't receive any exception and it continues to work. This exception happens freqently, randomly but not on every web method call.
The client (windows XP) authentication is windows, service is identified by SPN, services are self-hosted on windows service behind an NLB (windows server 2003).
Can anyone explain me what is happening here.

The exception stacktrace from the trace xml is:

<ExceptionString>
System.ServiceModel.Security.MessageSecurityException: The server rejected the upgrade request. ---> System.ServiceModel.ProtocolException: Error while reading message framing format at position 0 of stream (state: ReadingUpgradeRecord) ---> System.IO.InvalidDataException: More data was expected, but EOF was reached.
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
</ExceptionString>

Screenshot:

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

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

发布评论

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

评论(1

兮子 2024-09-24 13:38:16

不确定真正的问题是什么以及它是否与流媒体有关(我将深入探讨)。无论如何,您可以尝试在服务器端捕获异常并抛出 CommunicationException

catch (Exception ex)
{
    throw new CommunicationException(ex.Message, ex);
}

这样,客户端代理不应忽略异常,并且其状态应为“故障”。

Not sure what the real problem could be and if it's related to streaming (I'll dive in). Anyway you can try catch the exception on the server side and throw a CommunicationException instead.

catch (Exception ex)
{
    throw new CommunicationException(ex.Message, ex);
}

This way the client proxy should not ignore the exception and it's state should be "Faulted".

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