none
Unable to increase maxReceivedMessageSize for WCF/Azure (moved to the right forum) RRS feed

  • Question

  • I am attempting to increase the allowable size of messages being sent and received between an Azure WCF and a C# client.  I must be missing something because I can't seem to modify the bindings appropriately so that the alterations are applied.

    Below are the relevant configuration files.  My primary goal is increase the message size, and a secondary goal would be to insure that compression is being used by both the client and server.

    Note, that despite this question location, the most important aspect of this is to configure it so that Azure behaves properly.

    Any help would be greatly appreciated.

    This is the web.config:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" targetFramework="4.6.1" />
        <httpRuntime targetFramework="4.6.1" />
      </system.web>
        <system.serviceModel>
          <services>
            <service behaviorConfiguration="ServiceBehavior" name="SomeDataService.DataService">
              <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="SomeDataService.IDataService">
                <identity>
                  <userPrincipalName value="" />
                </identity>
              </endpoint>
              <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
          </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior">
              <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <bindings>
          <basicHttpBinding>
            <binding name="basicHttpBinding" maxReceivedMessageSize="2147483647"  maxBufferSize="2147483647" transferMode="Streamed"  >
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
              <security mode="None">
              </security>
            </binding>
            <binding name="basicHttpsBinding" maxReceivedMessageSize="2147483647"  maxBufferSize="2147483647" transferMode="Streamed"  >
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
              <security mode="None">
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
           
        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="https" />
            <add binding="basicHttpBinding" scheme="http" />
        </protocolMapping>    
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
    
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="false" />
          <urlCompression doStaticCompression="true" doDynamicCompression="true" />
        <httpCompression>
          <dynamicTypes>
            <clear />
            <add enabled="true" mimeType="text/*"/>
            <add enabled="true" mimeType="message/*"/>
            <add enabled="true" mimeType="application/x-javascript"/>
            <add enabled="true" mimeType="application/javascript"/>
            <add enabled="true" mimeType="application/json"/>
            <add enabled="false" mimeType="*/*"/>
            <add enabled="true" mimeType="application/atom+xml"/>
            <add enabled="true" mimeType="application/atom+xml;charset=utf-8"/>
          </dynamicTypes>
          <staticTypes>
            <clear />
            <add enabled="true" mimeType="text/*"/>
            <add enabled="true" mimeType="message/*"/>
            <add enabled="true" mimeType="application/javascript"/>
            <add enabled="true" mimeType="application/atom+xml"/>
            <add enabled="true" mimeType="application/xaml+xml"/>
            <add enabled="true" mimeType="application/json"/>
            <add enabled="false" mimeType="*/*"/>
          </staticTypes>
        </httpCompression>
      </system.webServer>
      <connectionStrings>
        <add name="Main" providerName="System.Data.SqlClient" connectionString="Server=tcp:sometracks.database.windows.net,1433;Initial Catalog=someSystemDev;Persist Security Info=False;User ID=somtracks;Password=******;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" />
      </connectionStrings>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>

    This is the ServiceDefinition.csdef for Azure:

    <?xml version="1.0" encoding="utf-8"?>
    <ServiceDefinition name="SomeDataService.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
      <WebRole name="SomeDataService" vmsize="Small">
        <Sites>
          <Site name="Web">
            <Bindings>
              <Binding name="Endpoint1" endpointName="Endpoint1"></Binding>
            </Bindings>
          </Site>
        </Sites>
        <ConfigurationSettings>
        </ConfigurationSettings>
        <Endpoints>
          <InputEndpoint name="Endpoint1" protocol="http" port="80" />
        </Endpoints>
      </WebRole>
    </ServiceDefinition>

    And this is the client's app.config:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
            <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
                <section name="SomeClient.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
            </sectionGroup>
        </configSections>
        <connectionStrings>
            <add name="SomeConnection" connectionString="XpoProvider=MSSqlServer;data source=localhost\SQLExpress;integrated security=SSPI;initial catalog=SomeSystem" />
            <add name="SomeClient.Properties.Settings.SomeSystemConnectionString"
                connectionString="Data Source=localhost\sqlexpress;Initial Catalog=SomeSystem;Integrated Security=True"
                providerName="System.Data.SqlClient" />
        </connectionStrings>
        <startup> 
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
        </startup>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpsBinding_IDataService">
                        <security mode="Transport" />
                    </binding>
                    <binding name="Debug_IDataService" />
                </basicHttpBinding>
          <customBinding>
            <binding name="CustomBinding_IDataService">
              <binaryMessageEncoding compressionFormat="GZip"/>
              <httpsTransport maxBufferPoolSize="20000000"
              maxReceivedMessageSize="20000000"/>
            </binding>
          </customBinding>
    
          </bindings>    
            <client>
                <endpoint address="http://localhost:55254/DataService.svc" binding="basicHttpBinding"
                    bindingConfiguration="Debug_IDataService" contract="DataServiceClient.IDataService"
                    name="Debug_IDataService" />
                <endpoint address="https://localhost:44327/DataService.svc" binding="customBinding"
                    bindingConfiguration="CustomBinding_IDataService" contract="DataServiceClient.IDataService"
                    name="CustomBinding_IDataService" />
            </client>
        </system.serviceModel>
        <userSettings>
            <SomeClient.Properties.Settings>
                <setting name="InlineGridEditing" serializeAs="String">
                    <value>False</value>
                </setting>
            </SomeClient.Properties.Settings>
        </userSettings>
    </configuration>


    • Edited by Devlin Gaza Wednesday, September 5, 2018 11:06 PM
    Wednesday, September 5, 2018 11:05 PM

All replies

  • Hi Devlin Gaza,

    From your configuration of the client-side app.config. I noticed that you have exposed a service endpoint on the server-side (If you want to use the HTTPS protocol, you should use the transport security to configure additional endpoints), But the configuration is not corresponding between the client-side and server-side.

    For the endpoint that uses basichttpibinding, you should ensure that the same configuration is configured on the client-side.

                      <basicHttpBinding>
                    <binding name="BasicHttpsBinding_IDataService" maxBufferPoolSize="2147483647"
              maxReceivedMessageSize="2147483647"
              maxBufferSize="2147483647" transferMode="Streamed" sendTimeout="00:10:00" receiveTimeout="00:10:00">
                        <security mode="Transport" />
                    </binding>
                    <binding name="Debug_IDataService" />
                </basicHttpBinding>

    The follow link guide us how to configure the transmitted message size between server-side and client-side. Wish it is useful to you.

    https://stackoverflow.com/questions/884235/wcf-how-to-increase-message-size-quota

    Feel free to let me know if you have any questions

    Best Regards

    Abraham
    Monday, September 10, 2018 1:25 AM
    Moderator