【发布时间】:2010-02-03 10:23:44
【问题描述】:
所以我们有控制台托管的 WCF 服务和 ASP.NET WEB 服务(在 IIS 上)。 经过一些艰难的操作后,WCF 服务必须将一些(大)数据返回给 ASP.NET Web 服务以进行下一步处理。我对小结果进行了测试,一切正常。 但是在对接近 4.5 MB 的序列化结果对象的真实数据进行测试后,在 wcf-client-server 通信中的客户端 ASP.NET Web Service 上出现错误。
这是我得到的错误:
套接字连接被中止。这可能是由错误引起的 处理您的消息或接收超时被超过 远程主机或底层网络资源问题。本地套接字 超时为“04:00:00”。内部异常:SocketException:“现有 连接被远程主机强行关闭”ErrorCode = 10054
消息大小由下一个绑定配置(在服务器和客户端上):
NetTcpBinding netTcpBinding = new NetTcpBinding();
netTcpBinding.TransactionFlow = true;
netTcpBinding.SendTimeout = new TimeSpan(0, 4,0, 0);
netTcpBinding.Security.Mode = SecurityMode.None;
netTcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.None;
netTcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
netTcpBinding.Security.Transport.ProtectionLevel = ProtectionLevel.None;
netTcpBinding.MaxReceivedMessageSize = 2147483647;
netTcpBinding.MaxBufferSize = 2147483647;
netTcpBinding.MaxBufferPoolSize = 0;
netTcpBinding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
netTcpBinding.ReaderQuotas.MaxArrayLength = int.MaxValue;
netTcpBinding.ReaderQuotas.MaxBytesPerRead = int.MaxValue;
netTcpBinding.ReaderQuotas.MaxDepth = 32;
netTcpBinding.ReaderQuotas.MaxNameTableCharCount = 16384;
MaxObjectsInGraph 属性在配置文件中配置。
你有什么建议吗?我还需要示例如何以编程方式在客户端和服务器上设置 MaxObjectsInGraph 属性。
感谢您的回答。
【问题讨论】: