gpt4 book ai didi

c# - WCF maxBytesPerRead 限制为 4096

转载 作者:太空宇宙 更新时间:2023-11-03 11:44:35 24 4
gpt4 key购买 nike

我在流模式下使用基本的 WCF Web 服务从服务器下载文件。

我已将服务器端的绑定(bind)指定为

     <basicHttpBinding>
<binding name="DBUpdateServiceBinding" closeTimeout="23:59:59"
openTimeout="23:59:59" receiveTimeout="23:59:59" sendTimeout="23:59:59"
maxReceivedMessageSize="10067108864" messageEncoding="Mtom"
transferMode="Streamed">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="8192" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>

我的客户端绑定(bind) xml 看起来像

  <bindings>
<basicHttpBinding>
<binding name="ws" closeTimeout="23:59:59" openTimeout="23:59:59"
receiveTimeout="23:59:59" sendTimeout="23:59:59" maxReceivedMessageSize="10067108864"
messageEncoding="Mtom" transferMode="Streamed">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="8192" maxNameTableCharCount="16384" />
<security>
<transport realm="" />
</security>
</binding>
</basicHttpBinding>
</bindings>

我正在尝试使用

下载文件
   byte[] buffer = new byte[32768];
while (true)
{
int read = serverStream.Read(buffer, 0, buffer.Length);
if (read <= 0)
break;
fs.Write(buffer, 0, read);
}

即使我指定了 maxBytesPerRead="8192",我在调用中可以读取的最大字节数也只有 4096。

最佳答案

除非您有非常具体的安全要求,否则您可能需要考虑将最大大小设置为 Int32.MaxValue。它将为您节省一些调试时间。然后根据需要将其调低到更合理的值。

关于c# - WCF maxBytesPerRead 限制为 4096,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3746638/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com