Question

I'm new to WCF and am trying to get my head around the labyrinth of configurations the services take. I have a rest service that can return an export of a table, which it larger than the default maxReceivedMessageSize. So I'm been trying to play with the config for this service/endpoint and I'm getting nowhere. Below if the gist of what I'm working on, what am I missing? I simply return List as either JSON or XML and I need to be able to return over the default threshold.

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

<services>
  <!-- defin service -->
  <service behaviorConfiguration="EPRestBehavior" name="EPRestDNS">
    <endpoint address="" 
              bindingConfiguration="ApiExportBinding"
              binding="webHttpBinding" 
              contract="IDNSRestService" />
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="EPRestBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>

  ...

</behaviors>
<bindings>
  <!-- Customizations for REST service -->
  <webHttpBinding>
    <binding name="ApiExportBinding" maxReceivedMessageSize="10485760"
                    maxBufferPoolSize="10485760" maxBufferSize="10485760" closeTimeout="00:03:00"
                    openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00">
      <readerQuotas maxDepth="32" maxStringContentLength="10485760"
                      maxArrayLength="10485760" maxBytesPerRead="10485760" />
      <security mode="None" />
    </binding>
  </webHttpBinding>
</bindings>

<standardEndpoints>
  <webHttpEndpoint>
    <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" />
  </webHttpEndpoint>
</standardEndpoints>

UPDATE 1 I've removed all of that config and tried something simper with the existing webHttpEndpoint section:

<standardEndpoints>
  <webHttpEndpoint>
    <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="1000000000" />
  </webHttpEndpoint>
</standardEndpoints>

with the same results. HTTP/1.1 502 Connection reset by peer

Was it helpful?

Solution

All this is why WCF is horrible. In the end I create a svclog on the server and the actual issue was hitting the limit in the default object graph. I added the new limit I want to the implementation, and that was that. 7+ hours just for a stupid thing like that.

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, MaxItemsInObjectGraph = 2147483646)]

OTHER TIPS

Does the exception occur on the service or the client side? A common mistake is that you change the values on the server but forget to change also on the client.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top