none
System.Net.WebException: The remote server returned an unexpected response: (413) Request Entity Too Large. RRS feed

  • Question

  • I have a WCF service, which is working fine whenever i receive a small or normal size request message. But When the user is trying to send a large message, Message size -> Approx 134 KB

    The remote server returned an unexpected response: (413) Request Entity Too Large.

    I have set the MaximumReceivedMessageSize to 2147483647 as mentioned in other post, but still the issue is resolved


    <?xml version="1.0"?>
    <configuration>
    
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="BasicHttpBinding_ITwoWayAsync" />
            <binding name="BasicHttpBinding_iCCService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" openTimeout="01:00:00" receiveTimeout="01:00:00" closeTimeout="01:00:00" sendTimeout="01:00:00">
              <security mode="Transport">
                <transport clientCredentialType="None" />
              </security>
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            </binding>
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://mastercc1.mcc.ad.com:70/MCCBizTalkService/MCCBizTalkReqResp.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITwoWayAsync"
            contract="MCCSvc.MCCBizTalkReqResp" name="BasicHttpBinding_ITwoWayAsync" />
        </client>
        <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="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>    
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
        <services>
          <service name="mccvfy">
    
            <endpoint binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_iCCService" contract="ICCService"  name="BasicHttpBinding_iCCService" />
    	
    
          </service>
        </services>
      </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="true"/>
      </system.webServer>
    </configuration>
    


    Any help is much appreciated

    Thursday, September 29, 2016 4:13 AM

All replies

  • Hi btsadmin,

    Is your configuration service side or client side? I am not sure whether it is service or client configuration, it has client and service node, and your service name and contract seem to wrong. They should be namespace.Service and namespace.IService.

    >> The remote server returned an unexpected response: (413) Request Entity Too Large.

    For this issue, you need to set maxReceivedMessageSize in the binding of service side, and then re-add your service reference in your client side.

    For more information about this, I suggest you refer the link below:

    # The remote server returned an unexpected response: (413) Request Entity Too Large

    http://stackoverflow.com/questions/20575946/the-remote-server-returned-an-unexpected-response-413-request-entity-too-larg

    In addition, if you still have this issue, I would suggest you modify the generated client configuration to add maxReceivedMessageSize settings.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, September 29, 2016 5:55 AM
  • Hi Edward, Thank you for your reply.

    It is a client side configuration. Sorry there was a mistake in the above web.config

    I have shared the latest below. I have updated the maximumReceivedMessageSize, but the issue is not resolving.

    the Service allows a maximum of 65KB eventhough it is set as 2147483647. Any help ?

    <?xml version="1.0"?>
    <configuration>
    
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="BasicHttpBinding_ITwoWayAsync" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" openTimeout="00:20:00" receiveTimeout="00:20:00" closeTimeout="00:20:00" sendTimeout="00:20:00">
              <security mode="Transport">
                <transport clientCredentialType="None" />
              </security>
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            </binding>
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://mastercc1.mcc.ad.com:70/MCCBizTalkService/MCCBizTalkReqResp.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITwoWayAsync"
            contract="MCCSvc.MCCBizTalkReqResp" name="BasicHttpBinding_ITwoWayAsync" />
        </client>
        <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"/>
            </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="true"/>
      </system.webServer>
    
    </configuration>
    

    Tuesday, October 4, 2016 7:52 PM
  • Hi btsadmin,

    Have you set maxReceivedMessageSize at server side? Could you share us your server side configuration? After you add maxReceivedMessageSize at server side, you need to re-add your service reference in client side.

    How did you host your service? I suggest you add a new endpoint address to check whether your service configuration is worked or the service uses the default configuration.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, October 6, 2016 5:59 AM