【转载】WCF Timeout knobs

http://social.msdn.microsoft.com/forums/en-US/wcf/thread/84551e45-19a2-4d0d-bcc0-516a4041943d/

Brief summary of binding timeout knobs...

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.

 

For your specific question, if you are using a session channel that requires network interaction at Open() time, I would use OpenTimeout. 

If not, you may have to use SendTimeout (but setting this to a small value would require all operation interactions to complete in a short period of time, which may be impractical if you are passing large messages or calling long-running request-reply operations).  Another option is to cast the client channel to (IContextChannel) and set the .OperationTimeout to a small value for only the first method call, but then set it back to a normal value for subsequent calls.

Note that in a number of cases, you may get feedback even if the timeout doesn't kick in.  For example, using BasicHttpBinding (a simple non-session binding without RM), I find that if I invoke a client operation on a server that is not listening, I get an EndpointNotFoundException ("No connection could be made because the target machine actively refused it.") in a second or two, regardless of the timeout values.

posted @ 2010-01-13 13:43  TerryGao  阅读(568)  评论(1编辑  收藏  举报