MaxReceivedMessageSize

Jul 20, 2009 at 5:17 PM

Hello,

Yet another question/problem.  I'm receiving an error related to the maxreceivedmessagesize default of 65536.

A problem on initial sync (have hooked up the project with my own data).  I know where (I think) to change this

in the WCF project, but think that it needs to be adjusted in the client app as well?  Have looked in the SyncComm.Proxy,

looking for something related to CreateDefaultBinding, but have had no luck.  Can anyone lead me in the

right direction to do this?

 

Thanks,

Scott

Jul 20, 2009 at 7:08 PM

Tried changing code ClientService.cs, CreateDefaultBinding() method to no avail:

  public static System.ServiceModel.Channels.Binding CreateDefaultBinding()
    {
        System.ServiceModel.Channels.CustomBinding binding = new System.ServiceModel.Channels.CustomBinding();
        binding.Elements.Add(new System.ServiceModel.Channels.TextMessageEncodingBindingElement(System.ServiceModel.Channels.MessageVersion.Soap11, System.Text.Encoding.UTF8));
       

        // remarked out the following line, created below with the MaxMessage properties set
        //binding.Elements.Add(new System.ServiceModel.Channels.HttpTransportBindingElement());

        // added the following to set binding properties

        System.ServiceModel.Channels.HttpTransportBindingElement httpBinding = new System.ServiceModel.Channels.HttpTransportBindingElement();
        httpBinding.MaxReceivedMessageSize = 2147483647;
        httpBinding.MaxBufferSize = 2147483647;
 
        binding.Elements.Add(httpBinding);

        return binding;
    }

 

Coordinator
Jul 21, 2009 at 2:32 PM

Hi Scott,

Yes you neeed increase MaxReceivedMessageSize on both server and client. However, try to decrease batch value. I think default value is set to 100.


Please let me know how about is this...

thanks,,

Jose M. Torres

Jul 21, 2009 at 2:48 PM

Jose,

I did increase MaxReceivedMessageSize in 2 places, but it doesn't seem to be recognized:

1st, in app.config in the Syncomm.Service.Host project, looks like this:


    <client>
      <remove contract="IMetadataExchange" name="sb" />
      <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingSettings"
        contract="SyncService.ISyncService" name="sb" />
    </client>
    <services>
      <service behaviorConfiguration="ISyncServiceBehavior" name="SyncComm.Service.SyncService">
        <endpoint address="Basic" binding="basicHttpBinding" name="BasicEndPoint"
          contract="SyncComm.Service.ISyncService" />
        <endpoint
          address ="/GZip"
          binding="customBinding"
          bindingConfiguration="BufferedHttpSampleServer"
          bindingName="BufferedHttpSampleServer"
          contract="SyncComm.Service.ISyncService"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://172.16.1.16:9999/SyncService" />
          </baseAddresses>
        </host>
      </service>
    </services>

 <bindings>
      <customBinding>
        <binding name="BufferedHttpSampleServer">
          <gzipMessageEncoding
              innerMessageEncoding="textMessageEncoding" />
          <httpTransport hostNameComparisonMode="StrongWildcard"
                         manualAddressing="False"
                         maxReceivedMessageSize="2147483647"
                         maxBufferSize ="2147483647"
                         authenticationScheme="Anonymous"
                         bypassProxyOnLocal="False"
                         realm=""
                         useDefaultWebProxy="True" />
        </binding>
      </customBinding>
      <basicHttpBinding>
        <binding name="basicHttpBindingSettings"
                 maxReceivedMessageSize="2147483647"
                 maxBufferSize="2147483647">
        </binding>
      </basicHttpBinding>
    </bindings>

 

Then, in ClientService.cs, in the SyncComm.Proxy project on the client side, I made the

changes I included in my initial post.  Am I missing something?  Or have I maybe set something

incorrectly in the APP.CONFIG?

Also, I had already changed batch size to 50 in AppRemoteProviderBase.cs in the Server

SyncApp.RemoteProvider project.  That would be the only place correct?

   // Set the requested batch size <font size="2">

 

</font>

   this.BatchSize = 50;

Sorry for all of the questions, but really appreciate the help!

Scott

 

Coordinator
Jul 21, 2009 at 3:11 PM

Hi again,

Don't worry, ask me any doubt you get.

Let's try to increase readerQuotas (maxArrayLength="xxx" maxStringContentLength="xxx") on server side. Try it and tell me the results....

 

Jul 21, 2009 at 3:31 PM

Thanks Jose,

I tried that.  Made the change to the APP.CONFIG server side.  Still getting TargetInvocationError,

error references the default message size of 65KB.  Below is my entry in APP.CONFIG just in case

I did something wrong...thanks again. (By the way, I'm using the GZIP custom encoding, not sure

if I should add the reader quotas to that custom binding configuration as well?  When I try, I get the

following error message at runtime: 

Invalid element in configuration. The extension name 'readerQuotas' is not registered in the collection at system.serviceModel/extensions/bindingElementExtensions. ).

<client>
      <remove contract="IMetadataExchange" name="sb" />
      <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingSettings"
        contract="SyncService.ISyncService" name="sb" />
    </client>
    <services>
      <service behaviorConfiguration="ISyncServiceBehavior" name="SyncComm.Service.SyncService">
        <endpoint address="Basic" binding="basicHttpBinding" name="BasicEndPoint"
          contract="SyncComm.Service.ISyncService" bindingConfiguration="basicHttpBindingSettings" />
        <endpoint
          address ="/GZip"
          binding="customBinding"
          bindingConfiguration="BufferedHttpSampleServer"
          bindingName="BufferedHttpSampleServer"
          contract="SyncComm.Service.ISyncService"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://172.16.1.16:9999/SyncService" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <customBinding>
        <binding name="BufferedHttpSampleServer">
          <gzipMessageEncoding
              innerMessageEncoding="textMessageEncoding" />
          <httpTransport hostNameComparisonMode="StrongWildcard"
                         manualAddressing="False"
                         maxReceivedMessageSize="2147483647"
                         maxBufferSize ="2147483647"

                         authenticationScheme="Anonymous"
                         bypassProxyOnLocal="False"
                         realm=""
                         useDefaultWebProxy="True" />
        </binding>
      </customBinding>
      <basicHttpBinding>
        <binding name="basicHttpBindingSettings"
         
maxReceivedMessageSize="2147483647"
          maxBufferSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
        </binding>
      </basicHttpBinding>
    </bindings>

 

 

Coordinator
Jul 21, 2009 at 4:05 PM

Scott,


Yes you need to configure just GZIP Endpoint at <binding name="BufferedHttpSampleServer">. I tried it out and that's work for my. Could you paste here entire Exception's Message??

 

Thanks for your patience...

Jul 21, 2009 at 4:24 PM

Here is the error message.  Can you show me your entry in CONFIG.APP?

Thanks,

Scott

{"TargetInvocationExeption"}

{"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."}

Stack Trace:

StackTrace "   at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess, StackCrawlMark& stackMark)\r\n   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\r\n   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)\r\n   at Microsoft.Synchronization.Data.ServerSyncProviderProxy.GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)\r\n   at Microsoft.Synchronization.SyncAgent.DownloadChanges(SyncGroupMetadata groupMetadata)\r\n   at Microsoft.Synchronization.SyncAgent.Synchronize()\r\n   at AppMobileSync.Form1.SyncNow()\r\n   at AppMobileSync.Form1.button1_Click(Object sender, EventArgs e)\r\n   at System.Windows.Forms.Control.OnClick(EventArgs e)\r\n   at System.Windows.Forms.Button.OnClick(EventArgs e)\r\n   at System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)\r\n   at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)\r\n   at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)\r\n   at System.Windows.Forms.Application.Run(Form fm)\r\n   at AppMobileSync.Program.Main()\r\n" string

Coordinator
Jul 21, 2009 at 4:52 PM

My App.config is such initial with maxReceivedMessageSize tag updated to 2147483647 and my client, on Sync() method at AppMobileSync project, has been modified as follows:

#region Compression configuration
// Create a CustomBinding
var customBinding = new CustomBinding();
// Create a compression binding element
var compressionBindingElmnt = new CompressionMessageEncodingBindingElement();
// ..and add to the custom binding
customBinding.Elements.Add(compressionBindingElmnt);

// Create an HttpTransportBindingElement and add that as well
var httpBindingElement =
new HttpTransportBindingElement();

httpBindingElement.MaxBufferSize = long.MaxValue;
        httpBindingElement.MaxReceivedMessageSize = long.MaxValue;
        httpBindingElement.MaxBufferPoolSize = long.MaxValue; // maybe this one is not necessary

customBinding.Elements.Add(httpBindingElement);
// Set endpoint
var endPoint = new EndpointAddress("http://10.0.2.15:9999/SyncService/GZip");
#endregion

If we are not lucky I'll try to create this scenario and test it again... let me know again ;-))
Jul 21, 2009 at 6:00 PM

Jose,

That did the trick!  Thank you for your assistance, much appreciated.

Moving on to Row filtering now, I've done a peer to peer sync process before this project,

using all Stored Procedures, not exactly sure yet how to hook those into this methodology,

hope you don't mind if I start a new discussion (unless of course I get lucky!).

Thanks again,

Scott

Coordinator
Jul 21, 2009 at 7:24 PM

Scott,

I really apreciate the effort you are doing by adopting SyncComm for your project. I'm curretnly working for enhancing it (in fact, now I improving exception handling that will be available soon) and any question or comment you drop here would really be appreciated.

Thus, thank to you.

Jose M. Torres