Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF - How to Increase Message Size Quota

I have a WCF Service which returns 1000 records from database to the client. I have an ASP.NET WCF client (I have added service reference in asp.net web application project to consume WCF).

I get the following message when I run the client application:

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.

Any help? How to increase message size quota?

like image 416
bugBurger Avatar asked May 19 '09 18:05

bugBurger


People also ask

How can I increase my quota size?

To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element". Reason of this problem: By default, the client machine supports only 65536. Last month, while working on web services, I needed to transfer a huge amount of data between server to client machines.

Is the maximum message size quota for incoming messages?

By default, the maximum message size quota for incoming messages that can be shared is 65536 bytes (64 Kb).


2 Answers

You'll want something like this to increase the message size quotas, in the App.config or Web.config file:

<bindings>     <basicHttpBinding>         <binding name="basicHttp" allowCookies="true"                  maxReceivedMessageSize="20000000"                   maxBufferSize="20000000"                  maxBufferPoolSize="20000000">             <readerQuotas maxDepth="32"                   maxArrayLength="200000000"                  maxStringContentLength="200000000"/>         </binding>     </basicHttpBinding> </bindings> 

And use the binding name in your endpoint configuration e.g.

... bindingConfiguration="basicHttp" ... 

The justification for the values is simple, they are sufficiently large to accommodate most messages. You can tune that number to fit your needs. The low default value is basically there to prevent DOS type attacks. Making it 20000000 would allow for a distributed DOS attack to be effective, the default size of 64k would require a very large number of clients to overpower most servers these days.

like image 159
Nate Avatar answered Oct 15 '22 17:10

Nate


If you're still getting this error message while using the WCF Test Client, it's because the client has a separate MaxBufferSize setting.

To correct the issue:

  1. Right-Click on the Config File node at the bottom of the tree
  2. Select Edit with SvcConfigEditor

A list of editable settings will appear, including MaxBufferSize.

Note: Auto-generated proxy clients also set MaxBufferSize to 65536 by default.

like image 41
Michael Rodrigues Avatar answered Oct 15 '22 16:10

Michael Rodrigues