How to increase maxReceivedMessageSize

2019-09-19 00:15发布

问题:

i have wcf service and i am sending large streams from service to client.

this is my code in client web config

<bindings>
      <basicHttpBinding>

        <binding name="Blabla" allowCookies="true"
                 maxReceivedMessageSize="2147483647"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647">
          <readerQuotas maxDepth="32"
               maxArrayLength="2147483647"
               maxStringContentLength="2147483647"/>
        </binding>
      </basicHttpBinding>
    </bindings>

when i wanted to set maxReceivedMessageSize to more than 2 gb, i get an error. it says "int32 value can not initialize that value". Is it possible to set it to 40 gb or bigger value?

回答1:

maxReceivedMessageSize can be set to more than int.MaxValue, but only if the transfer mode of the binding is set to Streamed. You should also not set maxBufferSize to 2GB, otherwise you may get a huge memory usage in the client.