繁体   English   中英

WCF 使用 nettcpbinding 时通信异常

[英]WCF communicationexception when using nettcpbinding

我们有一个基于 NetTCPBinding 的自托管 WCF 服务。 几周后,在 4000-5000 个请求后随机出现通信异常,之后所有请求都可以正常工作。 此外,如果我重复相同的失败请求,该请求也会起作用。 这种不当行为出现在一个客户安装中,另外 100 个 WCF 服务在相同的实现和 NetTCPBinding 下工作得很好。 从我们这边看,没有更新,问题在一夜之间就开始了。 我激活了服务跟踪查看器工具 - 但是我找不到导致此问题的任何内容。 So i checked windows updates: I have seen that there was (amongst others) following Windows Update https://support.microsoft.com/de-at/help/4538158/kb4538158 which indicates that Microsoft "solved" an issue for WCFNetTCP binding . 但是,他们似乎在这里破坏了一些东西:-)

于是我把NetTCPBinding改成了BasicHTTPBinding,这个异常就不再出现了。 但是,我们想使用 NetTCPBinding 而不是 BasicHTTPBinding... 还有其他人有这个问题吗?

通信错误/超时错误通常是由于客户端代理未正确关闭引起的。 我建议您将客户端代理/服务通道放在 Using 语句中。

using (ServiceReference1.ServiceClient client=new ServiceClient())
            {
                var result = client.Test();
                Console.WriteLine(result);
            }

此外,请尝试设置以下属性。

NetTcpBinding binding = new NetTcpBinding();
binding.MaxBufferSize = Int32.MaxValue;
binding.MaxBufferPoolSize = Int32.MaxValue;
binding.SendTimeout = new TimeSpan(0, 10, 0);
binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
binding.OpenTimeout = new TimeSpan(0, 10, 0);

如果问题仍然存在,请随时告诉我。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM