Reputation: 409
I have an ASP.NET (C#) 4.0 WCF application. I got message error:
Error : The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.
I have increased it into
maxBufferSize="2097152" maxBufferPoolSize="524288" maxReceivedMessageSize="2097152"
it works fine. But I am afraid that next time may be it will be over the quota again.
Can I set this maxBufferSize
and maxReceivedMessageSize
with no limit ?
thanks you in advance
Upvotes: 2
Views: 31654
Reputation: 2560
You should change buffersize, if you're using dynamically use this code
var binding = new BasicHttpBinding();
binding.ProxyAddress = new Uri(string.Format("http://{0}:{1}", proxyAddress, proxyPort));
binding.UseDefaultWebProxy = false;
binding.Security.Mode = BasicHttpSecurityMode.Transport;
binding.MaxReceivedMessageSize = Int32.MaxValue; //IMPORTANT
binding.MaxBufferSize = Int32.MaxValue; //IMPORTANT
binding.MaxBufferPoolSize = Int32.MaxValue;//IMPORTANT
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Basic;
if you're using webconfig use this code
<bindings>
<basicHttpBinding>
<binding name="basicHttp" allowCookies="true"
maxReceivedMessageSize="20000000"
maxBufferSize="20000000"
maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
Upvotes: 0
Reputation: 223247
Can I set this maxBufferSize and maxReceivedMessageSize with no limit ?
No. You can not do that.
Set your values to Max like:
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
MaxBufferSize is of type int
. So the max value it can support is Int32.MaxValue (2147483647) to avail the maximum allowable size. (Int.MaxValue
is just one byte shy of 2 GB of data)
MaxReceivedMessageSize on the other hand is of type long
or Int64
and the max value it supports is: 9,223,372,036,854,775,807
Upvotes: 6
Reputation: 3713
Also, if you're maxing out your buffer with big uploads or downloads, consider streaming as an alternative.
Upvotes: 0
Reputation: 754458
You cannot set it to "no limit" - how would you handle a limitlessly large message, anyway?
The maximum you can set it to is 2 billion (int.MaxValue
in .NET) - which corresponds to 2 GB (2'147'483'648 bytes) of data.
Is that enough for your needs?
Upvotes: 5