none
MaxReceivedMessageSize RRS feed

  • Question

  • I am using Microsoft Synchronization services to synchronize a SQL Server Compact Edition database with a SQL Server 2008 database. I used the netcfSvcUtil.exe tool to generate the wcf service the mobile client will use to connect to the server.

    The client uses a basicHttpBinding, which is required for WCT on the compact framework. The synchronization works fine for small amounts of data. When I try to synchronize larger amounts of data I receive an exception with the following message on the client:

    "The maximum message size quota for incoming messages(65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding."

    It took a while but I figured out how and where to change this on the client. In MyServiceClientContract I change the binding as it is created:


       Public Shared Function CreateDefaultBinding() As
    System.ServiceModel.Channels.Binding
           Dim binding As System.ServiceModel.Channels.CustomBinding =
    New System.ServiceModel.Channels.CustomBinding
           binding.Elements.Add(New
    System.ServiceModel.Channels.TextMessageEncodingBindingElement(System.ServiceModel.Channels.MessageVersion.Soap11,
    System.Text.Encoding.UTF8))
           'binding.Elements.Add(New
    System.ServiceModel.Channels.HttpTransportBindingElement)
           Dim be As New System.ServiceModel.Channels.HttpTransportBindingElement
           be.MaxBufferPoolSize = 300000
           be.MaxBufferSize = 300000
           be.MaxReceivedMessageSize = 300000
           binding.Elements.Add(be)
           Return binding
       End Function

    I have tested this and it appears to work. I am ready to deploy this for use but wanted to verify that I am not creating problems for myself down the road. I dont fully understand this buffer thing and had a few questions for folks with more knowledge about wcf:

    Should there be an upper limit to the maxreceivedmessagesize? The default is 65536. Best I could tell, the messages I was sending that caused exceptions with the default message size were 130,000. I raised the maxreceivedmessagesize to 300,000 and it worked.

    Question 1

    Would there be anything wrong with making the max 5,000,000 to lesson the liklihood of exceptions in the future?

    Question 2

    Do I need to maintain any relationship between the maxbuffersize, maxbufferpoolsize and maxreceivedmessagesize?

    Without going into too much detail on my application, the user collects survey data and transmits the results back to the server. In general these transactions are fairly small (30 records, each record holds a GUID, 3 integer fields, and a decimal field).

    The exceptions occurred when major changes were made to the survey and these changes were downloaded to the mobile device.

     

    Thank you.

    Wednesday, September 22, 2010 1:22 AM

Answers

  • afaik, you should set it to a value that your device memory can handle. no use setting the maxBuffersize to 2GB for example if your device has less than that amount of memory.

    for buffered messages (CF only support buffered, not streamed), the maxbuffersize is the same as maxreceivedmessagesize.

    • Marked as answer by Giantocr73 Wednesday, September 22, 2010 3:42 PM
    Wednesday, September 22, 2010 3:34 AM
    Moderator

All replies

  • afaik, you should set it to a value that your device memory can handle. no use setting the maxBuffersize to 2GB for example if your device has less than that amount of memory.

    for buffered messages (CF only support buffered, not streamed), the maxbuffersize is the same as maxreceivedmessagesize.

    • Marked as answer by Giantocr73 Wednesday, September 22, 2010 3:42 PM
    Wednesday, September 22, 2010 3:34 AM
    Moderator
  • Thank you. That answers the question about the maxreceivedmessagesize and maxBuffersize.

    I was able to find out about the maxbufferpoolsize at the following link:

    http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/d6e234d3-942f-4e9d-8470-32618d3f3212

    Thank you for your help.

    Wednesday, September 22, 2010 3:41 PM