WCF service timeout

20,844

Solution 1

There is no built in (out of the box) way to do this. All of the timeouts that you can set are related to transport settings. In short words, you have to do that yourself.

Please also see this answer about limiting WCF execution time.

Solution 2

You can set this up in your service bindings, the link below shows the values to set on the service side as well as client side.

http://geekswithblogs.net/smyers/archive/2011/10/05/wcf-service-message-timeouts-size-limits-tips-and-tricks.aspx

Solution 3

We can set server side time out in "Binding" with:

Binding.ReceiveTimeout

This is the timeout that specifies how long the service can wait from the beginning of receiving a request until the message is processed. It’s server-side setting. When you send a large message to the service and the service needs long time to process, you would need to increase this setting.

http://msdn.microsoft.com/en-us/library/ms731361.aspx

Using these two timeouts should solve most timeout problems. However, when a WCF service is hosted in IIS/ASP.NET, another setting would also control the lifetime of the request:

HttpRuntimeSection.ExecutionTimeout

<configuration>
  <system.web>
  <httpRuntime executionTimeout="600"/>
  </system.web>
</configuration>
Share:
20,844
zimdanen
Author by

zimdanen

Updated on September 06, 2022

Comments

  • zimdanen
    zimdanen over 1 year

    Is there a way to set a tiemout on the service side so that the request stops processing if it exceeds the timeout? I know I can time the request out on the client side, but that doesn't stop the processing of the request on the server.

    I've tried adding the following binding:

    <basicHttpBinding>
        <binding name="timeout" receiveTimeout="00:01:00" closeTimeout="00:01:00" openTimeout="00:01:00" sendTimeout="00:01:00" />
    </basicHttpBinding>
    

    I've also tried adding the following in the system.web node (separately and together with the above):

    <httpRuntime executionTimeout="60" /> <!-- timeout after 60 seconds -->
    
  • zimdanen
    zimdanen about 12 years
    That's a good article, but setting the timeouts on the binding doesn't seem to work. Neither does setting the httpRuntime executionTimeout.
  • zimdanen
    zimdanen about 12 years
    See my most recent edit - that doesn't seem to limit the time from start to end of the full service call, which is what I'm trying to do.
  • zimdanen
    zimdanen about 12 years
    Thanks. May have to wait for a later project, then, since I won't have time to get a custom solution into the current project.
  • D.R.
    D.R. about 8 years
    AFAIK that is not true. For more information on ReceiveTimeout see rauch.io/2015/06/25/all-wcf-timeouts-explained