WCF Service Sending Large Images To Client RRS feed

  • Question

  • Hello,

    I have a WCF service that scans a disk for images and when it finds them it is sending them to connected clients as byte arrays.  I'm using callback with wsDualHttpBinding.  The images I'm sending are very large and it's throwing the error "The remote server returned an unexpected response: (413) Request Entity Too Large."  I've looked and looked for a solution but the ones I've seen all relate to basicHttpbinding, which to my knowledge can't be used with callbacks.  Below is my server config file, any help would be greatly appreciated.

    <?xml version="1.0" encoding="utf-8" ?>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
          <service name="Test_Server.Service.TestService" behaviorConfiguration="ServiceBehavior">
                <add baseAddress="http://localhost:5050/TestService" />
            <!-- Service Endpoints -->
            <endpoint address="http://localhost:5050/TestService" binding="wsDualHttpBinding" contract="Test_Server.Service.ITestService" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            <behavior name="ServiceBehavior">
              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="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"/>

    • Edited by JBHowl Friday, November 1, 2019 12:56 PM
    Friday, November 1, 2019 12:55 PM

All replies

  • The problem is not on the server-side. It is on the client-side that is receiving the data from the service, and you should change the default settings to their maximum sizes, concerning readerQuotas.

    On the other hand, if the services was receiving large data from the client, you would override the readerQuotas on the service-side by using a custom binding. 

    Friday, November 1, 2019 8:40 PM
  • Hi,
    Please consider the below configuration,

          <service name="WcfService1.Service1">
            <endpoint address="" binding="wsDualHttpBinding" contract="WcfService1.IService1" bindingConfiguration="mybinding"></endpoint>
            <binding name="mybinding" maxReceivedMessageSize="2147483647">
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>

    Then apply the settings on both the server-side by using BindingConfiguration property.

    Feel free to let me know if the problem still exists
    Best Regards

    Monday, November 4, 2019 6:46 AM