【发布时间】:2011-10-25 16:10:07
【问题描述】:
我有一个 windows 服务和一个 winform 应用程序,它们使用 WCF 通过 TCP 相互通信。
我有时不得不交换大量数据,我在客户端遇到了CommunicationException。现在我很难找到要更改的属性和位置(在服务器端还是客户端?)。
当服务器向客户端返回一个值是 2-uple(我自己的实现)的两个双精度数组时,就会出现问题:Tuple<Double[], Double[]>(两个数组始终具有相同的长度)。
我注意到当数组的长度为22 000 时没有错误,但是当数组的长度为44 000 时会抛出CommunicationException。
这是我关于netTcpBinding 部分的App.config 文件:
- 在服务器上:
<netTcpBinding>
<binding name="MyBindingConf"
maxReceivedMessageSize="5000000"
sendTimeout="00:05:00">
<readerQuotas maxArrayLength="67108864"
maxStringContentLength="67108864"/>
<security mode="None" />
</binding>
</netTcpBinding>
- 在客户端:
<netTcpBinding>
<binding name="MyBindingConf"
maxReceivedMessageSize="5000000"
sendTimeout="00:59:00">
<readerQuotas maxArrayLength="67108864"
maxStringContentLength="67108864"/>
<security mode="None" />
</binding>
</netTcpBinding>
您能否指出要更改哪个属性以及更改哪一侧?
PS:这不是超时问题。
编辑
我现在在服务器和客户端上都有相同的nettcpbindingconfiguration:
<bindings>
<netTcpBinding>
<binding name="MyBindingConf"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
sendTimeout="00:30:00">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
同样的serviceBehavior:
<behaviors>
<serviceBehaviors>
<behavior name="Debug">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
然后我在客户端上得到一个NetDispatcherFaultException,建议我增加maxArrayLength 或maxItemsInObjectGraph。但对我来说,这些值已经在很大程度上设置为我需要传输的内容,并且也设置为最大值!
这是InnerException 消息:
读取 XML 数据时,已超出最大数组长度配额 (19502) 或对象图中的最大项目配额。可以通过更改 XmlDictionaryReaderQuotas 上的 MaxArrayLength 属性或 MaxItemsInObjectGraph 设置来增加这些配额。
有什么线索吗? 19 502 这个数字是从哪里来的?
【问题讨论】:
-
你的
在客户端和服务器端都设置了吗? -
@ChrisNel52:我都更新了 Q。
-
@Otiel - 您是否使用 bindingConfiguration 属性引用您在端点中配置的绑定?如果不是,您将获得绑定的默认值,而不是您设置和预期的值。
-
@Tim:是的,我是:
<endpoint binding="netTcpBinding" bindingConfiguration="MyBindingConf" contract="blah blah" name="blah blah" /> -
@Otiel 这又是一个悬而未决的问题吗?赏金?如果是,那么您现在的新问题是什么:)
标签: c# wcf nettcpbinding