61

How do the timeouts work in WCF? I know for example that you can configure sendTimeout and receiveTimeout for a clients binding. But how do they work?

MSDN describes sendTimeout as:

A TimeSpan value that specifies the interval of time provided for a send operation to complete. This value should be greater than or equal to Zero. The default is 00:01:00.

What are send operations/receive operations?

informatik01
  • 16,038
  • 10
  • 74
  • 104
TruckerG
  • 1,289
  • 1
  • 13
  • 14

3 Answers3

62

Client side:

  • SendTimeout is used to initialize the OperationTimeout, which governs the whole interaction for sending a message (including receiving a reply message in a request-reply case). This timeout also applies when sending reply messages from a CallbackContract method.
  • OpenTimeout and CloseTimeout are used when opening and closing channels (when no explicit timeout value is passed).
  • ReceiveTimeout is not used.

Server side:

  • Send, Open, and Close Timeout same as on client (for Callbacks).
  • ReceiveTimeout is used by ServiceFramework layer to initialize the session-idle timeout.

The source is Brian McNamara on MSDN forums.

Martin Liversage
  • 104,481
  • 22
  • 209
  • 256
Brian
  • 117,631
  • 17
  • 236
  • 300
  • If I set OperationTimeout to a very high value, and sendTimeout to a ridiculously small value, which in essence should timeout, I never get a timeout exception. Can anyone tell me how I can set up an example as to trigger the sendTimeout exception? – Didier A. May 18 '12 at 13:39
  • My WCF service copies files and returns callbacks on the progress. It was timing out. After reading this answer I increased all timeout values except ReceiveTimeout, despite WCF error message which said to increase ReceiveTimeout. That didn't work. What worked, at least in my case, was to increase ReceiveTimout. – Tony D Oct 02 '13 at 20:09
  • 1
    I discovered that this topic is too much generic: WCF deployed in Cassic vs Integrated Pipeline expose different timeout behaviors. This answer may satisfy "native" WCF like netTcpBinding, but in case of Httphandler managed WCF like basichttpbinding if you execute a very long CPU bound job inside operation contract IIS may KILL WCF before closetimeout (server side)!! In this case I suggest to revise **IIS Application Pool** timeouts **also** , ping and shutdown timeouts – Diego Scaravaggi Nov 07 '13 at 19:30
  • Just make it clear to _OperationTimeout_. According to my tests, OpenTimeout and SendTimeout have nothing to do with the time taken by the business logic layer on the other side (i.e., the Serve side) to complete the operation logic. The time taken by the operation logic is actually governed OperationTimeout. For instance, if set the OpenTimeout to 1 min and OperationTimeout to 2 mins, after the wcf client establishes the connection successfully with the server, the operation logic is running, and then the db takes 3 mins, now it won't cause OpenTimeout, but will cause OperationTimeout. – cateyes Dec 30 '13 at 22:34
9

See "Timeouts in WCF and their default values" http://blogs.msdn.com/b/hongmeig/archive/2010/03/06/timeouts-in-wcf-and-their-default-values.aspx

Timeouts on binding-SendTimeout, ReceiveTimeout, OpenTimeout and CloseTimeout. They can be set easily either through config or code on the Binding. The default value for those are 1 minute.

ServiceHost has OpenTimeout and CloseTimeout. Default for OpenTimeout is 1 minute, and default for CloseTimeout is 10 seconds.

Timeouts on client side channel. There is an OperationTimeout, which you can set it by casting the channel to IContextChannel. The default for this is also 1 minute. Ttimeout on tcp transport, called ChannelInitializationTimeout, and its default value is 5 seconds.

ASPNET. There are shutdown timeout, just like the service host close timeout, default is 90 seconds. ExecutionTimeout, just like our operation timeout, default is 110 seconds.

Community
  • 1
  • 1
Michael Freidgeim
  • 26,542
  • 16
  • 152
  • 170
4

In addition to what was on that post, there's also the Operation Timeout defined on the client end. See this:

http://final-proj.blogspot.com/2009/09/wcf-timeouts.html