netHttpBinding:最大字符串内容长度配额

时间:2019-03-04 11:29:06

标签: c# wcf config duplex nethttpbinding

即使我确实将绑定配置从服务器复制到客户端配置,也遇到了这个异常。

客户端:

<client>
  <endpoint 
    address="http://localhost/ConfiguratorServer" 
    binding="netHttpBinding" 
    bindingConfiguration="BindingConfiguratorServer" 
    contract="<redacted>.IConfiguratorServer" />
</client>

<bindings>
  <netHttpBinding>
    <binding 
        name="BindingConfiguratorServer" 
        messageEncoding="Binary" 
        transferMode="Streamed" 
        maxReceivedMessageSize="1000000000" 
        openTimeout="00:00:30" 
        closeTimeout="00:00:30" 
        sendTimeout="00:10:00" 
        receiveTimeout="00:10:00">
      <readerQuotas maxStringContentLength="1000000000" maxArrayLength="1000000000" />
      <security mode="None" />
      <webSocketSettings transportUsage="WhenDuplex" />
    </binding>
  </netHttpBinding>
</bindings>

服务器端:

<services>
  <service name="<redacted>.ConfiguratorServer">
    <endpoint 
       address="" 
       binding="netHttpBinding" 
       bindingConfiguration="BindingConfiguratorServer" 
       contract="<redacted>.IConfiguratorServer" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/ConfiguratorServer" />
      </baseAddresses>
    </host>
  </service>
</services>

<bindings>
  <netHttpBinding>
    <binding 
        name="BindingConfiguratorServer" 
        messageEncoding="Binary" 
        transferMode="Streamed" 
        maxReceivedMessageSize="1000000000" 
        openTimeout="00:00:30" 
        closeTimeout="00:00:30" 
        sendTimeout="00:10:00" 
        receiveTimeout="00:10:00">
      <readerQuotas maxStringContentLength="1000000000" maxArrayLength="1000000000" />
      <security mode="None" />
      <webSocketSettings transportUsage="WhenDuplex" />
    </binding>
  </netHttpBinding>
</bindings>

1)它适用于许多连接,但对于那些可能违反了8192限制的连接失败。

2)我正在从代码创建双工通道,而双工通道工厂的(在客户端)绑定包含maxStringContentLength = 1000000000。我不明白。

这是怎么了?

完全例外:

反序列化类型为System.Object的对象时发生错误。读取XML数据时,已超出最大字符串内容长度配额(8192)。通过更改在创建XML阅读器时使用的XmlDictionaryReaderQuotas对象的MaxStringContentLength属性,可以增加此配额。

编辑:

现在,我将messageEncoding切换为Text,它可以工作了。我很困惑。

编辑2:

在测试方案中。我发送的字节数组的长度在10k和20k之间。我确定限制为 16384 ,而不是 8192 Binary + Streamed(或StreamedResponse)对于16k以上的大小似乎无法正常工作。这是某种限制吗?

0 个答案:

没有答案