none
The remote server response an unexpected response (413).HTTP 413 Request Entity too Large – RRS feed

  • Question

  • Hiii,

        i have a webservice saving emails.My webservice url is https

    when i save large emails(big data) its not saving and giving me this error.

    "The remote server response an unexpected response (413).HTTP 413 Request Entity too Large"..

    My service web config is.

    <?xml version="1.0"?>
    <configuration>

      <appSettings>   
       
      </appSettings>

      <system.web>
        <compilation debug="true" targetFramework="4.5.2" />
        <httpRuntime targetFramework="4.5.2" 
                     maxRequestLength="2147483647"/>
      </system.web>
      
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding
              name="StreamedResponseBinding"
              transferMode="Streamed"
              maxBufferPoolSize="2147483647" 
              maxReceivedMessageSize="2147483647"  
             
              messageEncoding="Text"
              closeTimeout="00:25:00"
              openTimeout="00:30:00" 
              receiveTimeout="00:30:00" 
              sendTimeout="00:30:00" >
              <!--messageEncoding="Mtom"-->
              <readerQuotas  
                  maxDepth="32" 
                  maxStringContentLength="2147483647" 
                  maxArrayLength="2147483647" 
                  maxBytesPerRead="2147483647" 
                  maxNameTableCharCount="2147483647" />
            </binding>
            
          </basicHttpBinding>
        </bindings>

        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- 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="false"/>
              <dataContractSerializer maxItemsInObjectGraph="2147483647"></dataContractSerializer>
            </behavior>
          </serviceBehaviors>
        </behaviors>

        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="https" />
        </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"/>
      </system.webServer>

    </configuration>

    My Cleint web config is

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      
      <system.web>
        <httpRuntime maxRequestLength="102400" />
      </system.web>
      <system.serviceModel>

        <bindings>
          <basicHttpBinding>
            <binding name="BasicHttpsBinding_O" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00"
    sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
              <security mode="Transport" />
              <!--
              <security mode="None">
                <transport clientCredentialType="None" proxyCredentialType="None"
                    realm="" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
              </security>-->
            </binding>
          </basicHttpBinding>
          
        </bindings>
        <client>
          <endpoint address="https://abc.xyz/hjjj/abc.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpsBinding_O"
            contract="O.O" name="BasicHttpsBinding_O" />
        </client>
        <behaviors>      
          <endpointBehaviors>
            <behavior >
              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
          </endpointBehaviors>
        </behaviors>
      </system.serviceModel>
    </configuration>

      

    Friday, June 14, 2019 1:13 PM

Answers

  • Hi,

    The reason caused the issues mainly due to the configuration on the server side. try to apply the related configuration over HTTPS.  Please refer to the below code snippets.
    Server side web.config

      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <bindings>
          <basicHttpsBinding>
            <binding name="mybinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
              <readerQuotas
        maxDepth="32"
        maxStringContentLength="2147483647"
        maxArrayLength="2147483647"
        maxBytesPerRead="2147483647"
        maxNameTableCharCount="2147483647" />
            </binding>
          </basicHttpsBinding>
        </bindings>
        <protocolMapping>
          <add binding="basicHttpsBinding" scheme="https" bindingConfiguration="mybinding"/>
        </protocolMapping>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
    


    Feel free to let me know if the problem still exits.
    Best Regards
    Abraham

    Monday, June 17, 2019 3:24 AM
    Moderator

All replies

  • Hi,

    The reason caused the issues mainly due to the configuration on the server side. try to apply the related configuration over HTTPS.  Please refer to the below code snippets.
    Server side web.config

      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <bindings>
          <basicHttpsBinding>
            <binding name="mybinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
              <readerQuotas
        maxDepth="32"
        maxStringContentLength="2147483647"
        maxArrayLength="2147483647"
        maxBytesPerRead="2147483647"
        maxNameTableCharCount="2147483647" />
            </binding>
          </basicHttpsBinding>
        </bindings>
        <protocolMapping>
          <add binding="basicHttpsBinding" scheme="https" bindingConfiguration="mybinding"/>
        </protocolMapping>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
    


    Feel free to let me know if the problem still exits.
    Best Regards
    Abraham

    Monday, June 17, 2019 3:24 AM
    Moderator
  • Thanks abraham .

     It is working perfectly.

     I have changed these things in my config

     1) <basichttpbinding> to <basichttpsbinding>

     2)<given name to binding and given to binding configuration in <protocolMapping>

     3)maxBufferSize="2147483647"> in  <binding>

      4)includeExceptionDetailInFaults="true"

      and also commented "tranfermode"

      after these changes its working correctly.

     



    shweta gopi


    Monday, June 17, 2019 9:04 AM