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?


Solution 1:

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.

Solution 2:

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.

Solution 3:

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