DamianPawski
DamianPawski

Reputation: 375

WCF returns 404 for large request, maxReceivedMessageSize="2147483647"

Our WCF service on large request returns following error:

"System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at http://xxx.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.

For small requests everything works fine and I am getting correct response from WCF service, the issue is only with large requests.

Settings on the client are as follow:

 <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ITestService" openTimeout="00:05:00" sendTimeout="00:05:00" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" >
          <readerQuotas maxDepth="2147483647" maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647"
            maxNameTableCharCount="2147483647"/>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:33333/TestService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITestService" contract="TestService.ITestService" name="BasicHttpBinding_ITestService" />
    </client>
  </system.serviceModel>

The settings of the WCF service:

 <bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="2147483647" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483646" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>

What can be the issue?

Upvotes: 5

Views: 2288

Answers (2)

Sukhdeep Singh
Sukhdeep Singh

Reputation: 50

In my case, it was not working even after trying all solutions and setting all limits to max. In last I found out that a Microsoft IIS filtering module Url Scan 3.1 was installed on IIS/website, which have it's own limit to reject incoming requests based on content size and return "404 Not found page".

It's limit can be updated in %windir%\System32\inetsrv\urlscan\UrlScan.ini file by setting MaxAllowedContentLength to the required value.

For eg. following will allow upto 300 mb requests

MaxAllowedContentLength=314572800

Upvotes: 0

DamianPawski
DamianPawski

Reputation: 375

In this case, the error was not with WCF but with the IIS settings. The Message was to large for IIS, I have added "maxAllowedContentLength" to the web.config on the server.

<system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="2200000000"/>
      </requestFiltering>
    </security>

The error message was misleading.

Upvotes: 15

Related Questions