8

I have a self-hosting WCF service accepting messages via HTTPS.

A message is being sent from a Java application, which receives the response:

HTTP/1.1 413 Request Entity Too Large
Content-Length: 0
Server: Microsoft-HTTPAPI/2.0
Date: Wed, 19 Sep 2012 09:05:34 GMT
Connection: close

I am not attempting to upload a file, just send an XML/SOAP message, which is 78kb. I have tried upping my max message and buffer sizes but to no avail.

  <binding name="SecuredNoProxy" openTimeout="00:00:10" sendTimeout="00:00:10">
      <textMessageEncoding messageVersion="Soap11WSAddressing10" />
      <security includeTimestamp="true" enableUnsecuredResponse="true">
          <localClientSettings timestampValidityDuration="00:15:00" />
      </security>
      <httpsTransport manualAddressing="false" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" allowCookies="false" bypassProxyOnLocal="true" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="false" requireClientCertificate="true" />
  </binding>

Please let me know if I can supply any additional information.

WCF Trace Log

Receive bytes on connection 'https://localhost'

Activity boundary (Start)

Connection information

Throwing an exception (Error)

The exception is:

System.ServiceModel.ProtocolException, System.ServiceModel, Version=4.0.0.0, Culture=neutral

Community
  • 1
  • 1
Fenton
  • 241,084
  • 71
  • 387
  • 401
  • Enable [WCF Tracing](http://msdn.microsoft.com/en-us/library/ms733025(v=vs.100).aspx) to see if the message is being processed by WCF or not. That message looks like its coming from the HTTP host component, not the WCF plumbing. – Sixto Saez Sep 19 '12 at 12:01
  • @SixtoSaez - I have added the WCF trace log information. – Fenton Sep 19 '12 at 13:02

2 Answers2

7

As I eluded to in the question, this is very much related to the binding configurations. In particular, maxReceivedMessageSize.

maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"

This is the correct area to change (probably not to make things quite this big though as it will leave you potentially vulnerable to denial of service attacks). Determine a sensible value based on your actual messages.

The outbound endpoint was correctly configured but the inbound endpoint wasn't - it was:

<httpsTransport requireClientCertificate="true" />

Which meant it was using the default value of 65536, which isn't enough for the message being sent. So it is really a case of checking the endpoints really carefully, especially if they are similarly named.

Fenton
  • 241,084
  • 71
  • 387
  • 401
  • 1
    Steve I know it's been a while since you answered this, but could you elaborate on what you meant by outbound vs. inbound endpoints? Thanks. – antscode Mar 05 '14 at 14:16
  • 1
    It is all a bit of a haze. Thank goodness for lightweight REST services I haven't had to look at this kind of thing for a while. Despite this, I meant "outbound" = "the service" and "inbound" = "the caller" (I think!) – Fenton Mar 05 '14 at 15:11
2

For me it was maxRequestLength under system.web:

<system.web>
    <compilation debug="true" targetFramework="4.0" />
    <customErrors mode="Off"/>
    <httpRuntime
        maxRequestLength="2147483647"
        executionTimeout="300" />
</system.web>
Jim Neff
  • 326
  • 2
  • 7