|
-
Jun 5th, 2013, 09:03 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Need help with WCF error: maximum message size quota... exceeded
Okay, I'm writing my first WCF server application, and it's working except for this. When the service tries to return more than a hundred or so rows, I get the following 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.
What is this telling me, and how do I fix it?
At the moment, I'm still running this service temporarily locally auto-hosted within VS2012 (WcfSvcHost). I'll worry about hosting it with IIS later... once I get it working.
I get this error using both my custom client AND the Wcf Test Client... it works when returning 89 rows, but fails with that error message when returning 102 rows.
Any thoughts on how to correct this error?
Last edited by HongKongCV; Jun 5th, 2013 at 09:07 PM.
-
Jun 5th, 2013, 09:30 PM
#2
Re: Need help with WCF error: maximum message size quota... exceeded
There are numerous size limits that you can set in the config files of both the service and the client and that is one of them. Here are some snippets from the config files of a WCF service and the web site that consumes it from one of our applications, although not necessarily containing production values:
xml Code:
</system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="dxWsBinding" maxReceivedMessageSize="1073741824">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None" >
<transport clientCredentialType="None" />
<message establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
xml Code:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="dxWsBinding" maxReceivedMessageSize="1073741824">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None" >
<transport clientCredentialType="None" />
<message establishSecurityContext="false" />
</security>
</binding>
<binding name="phiscoLongTimeoutBinding"
maxReceivedMessageSize="1073741824"
receiveTimeout="00:10:00"
sendTimeout="00:10:00">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None" >
<transport clientCredentialType="None" />
<message establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
Note the 'maxReceivedMessageSize' attribute in there. Do put a bit of thought into the values you use and don't just use the maximum values arbitrarily. You can find out what each element and attribute means using the F1 key.
-
Jun 6th, 2013, 08:52 AM
#3
Thread Starter
Hyperactive Member
Re: Need help with WCF error: maximum message size quota... exceeded
Okay, I've tried variations on this and it still isn't working. I'm getting the same error... despite your caution, I've fiddled with the numbers until they are quite large, just to see if I could get it to work. So far no joy... Let me show you what I have.
This is the relevant portion of the app.config for the service (I'm doing all my testing within the VS 2012 environment using WcfSvcHost). It didn't like the wsHttpBinding so I ended up using basicHttpBinding instead.
Code:
<system.serviceModel>
<services>
<service name="PolicyMaintenanceService.PolicyMaintenanceService">
<endpoint address="" binding="basicHttpBinding" contract="PolicyMaintenanceService.IPolicyMaintenanceService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:/* hosting address data */" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647"
maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
And this is the app.config for the client app:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding_IPolicyMaintenanceService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:/* Hosting address data */"
binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_IPolicyMaintenanceService"
contract="PolicyServiceRef.IPolicyMaintenanceService" name="basicHttpBinding_IPolicyMaintenanceService" />
</client>
</system.serviceModel>
</configuration>
The application works for queries returning 71 or 89 rows, but fails with that "size limit exceeded" error message for queries returning 102 rows. What am I doing wrong, here?
-
Jun 6th, 2013, 08:59 AM
#4
Re: Need help with WCF error: maximum message size quota... exceeded
The attribute is 'maxReceivedMessageSize' so it's the receiving end that's the issue. You say that your service is returning a number of rows so it's presumably the client that's on the receiving end but I don't see where you've set 'maxReceivedMessageSize' for the client.
-
Jun 6th, 2013, 09:07 AM
#5
Re: Need help with WCF error: maximum message size quota... exceeded
One thing to consider is just how BIG a return set can be. You are setting sizes around 2MB. While what JMC said is correct, you might also consider whether or not 2MB really is big in this case.
One of the projects that I use WCF for sends datasets across the wire. The dataset is likely to contain one record, 1 to hundreds of sub records in each of two different tables, and for one of those other tables, each record might also have one to five sub records in each of two other tables. Therefore, I could be sending hudreds or thousands of records with each call. If I send 1000 records, then each record would have to be less than 2000 bytes for your limits to work. Some of the records will clearly be smaller, but an integer is 4 bytes, a double would be 8, a GUID (which I use for primary keys) would be considerably more. That all adds up pretty quick.
One thing I do to keep the sizes down is to compress the dataset before sending it. You might consider that, if you have not already, but in any case you should try to come up with a rough idea of how large your largest likely message will be, then get bigger than that. 2MB may be sufficient, but it isn't really all that large.
My usual boring signature: Nothing
 
-
Jun 6th, 2013, 10:07 AM
#6
Thread Starter
Hyperactive Member
Re: Need help with WCF error: maximum message size quota... exceeded
BINGO!
Setting the message and buffer sides on the client end worked like a charm. All 102 rows were returned without a hiccup. I did a more expansive test, and it returned 1152 rows! So that particular problem has been solved... thanks jmcilhinney!!
Shaggy, the 2 MB size I'm using now will probably be plenty... but I will keep it in mind as I move forward and add more functionality.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|