简体   繁体   English

WCF中OperationTimeout和SendTimeout的区别

[英]Difference between OperationTimeout and SendTimeout in WCF

After quite a bit of searching, I could not find the answer to this question.经过相当多的搜索,我找不到这个问题的答案。

What is exact difference between OperationTimeout and SendTimeout ? OperationTimeoutSendTimeout之间的确切区别是什么? I read OperationTimeout is a subset of SendTimeout and SendTimeout includes writing message in the channel.我读到OperationTimeoutSendTimeout一个子集, SendTimeout包括在通道中写入消息。 If you give more details that would be great.如果您提供更多详细信息,那就太好了。

My second question is I have client call to a service where I just want to set timeout between soon after request sent to the server and soon after received reply from the server.我的第二个问题是我有客户端调用一个服务,我只想在请求发送到服务器后不久和从服务器收到回复后不久设置超时。 How to set this timeout?如何设置这个超时?

I'd like to propose reading this answer from Brian McNamara over on the MSFT forums:我想建议在 MSFT 论坛上阅读 Brian McNamara 的这个答案

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). SendTimeout 用于初始化 OperationTimeout,它控制发送消息的整个交互(包括在请求-回复情况下接收回复消息)。 This timeout also applies when sending reply messages from a CallbackContract method.当从 CallbackContract 方法发送回复消息时,此超时也适用。
  • OpenTimeout and CloseTimeout are used when opening and closing channels (when no explicit timeout value is passed). OpenTimeout 和 CloseTimeout 在打开和关闭通道时使用(当没有明确的超时值被传递时)。
  • ReceiveTimeout is not used.不使用 ReceiveTimeout。

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. ServiceFramework 层使用 ReceiveTimeout 来初始化会话空闲超时。

I know it is an old question and WCF has reached its end of life - nevertheless I stumbled upon this exact problem.我知道这是一个老问题,WCF 已经走到了生命的尽头——不过我偶然发现了这个确切的问题。

The answer which Vincent quoted from Brian McNamara is correct ( SendTimeout is used to initialize the OperationTimeout ). Vincent 从 Brian McNamara 引用的答案是正确的( SendTimeout用于初始化OperationTimeout )。 It is just not complete.它只是不完整。

The SendTimeout also covers the time which is used for sending (the write operation itself) the data! SendTimeout还包括用于发送(写操作本身)数据的时间! See the Microsoft Docs 请参阅 Microsoft 文档

This really makes a difference if you increase the OperationTimeout for certain heavy services.如果您为某些繁重的服务增加OperationTimeout ,这确实会有所不同。 But do not increase the SendTimeout on the binding (for all services!) and a whole lot of data has to be transmitted via a poor line.但是不要增加绑定上的SendTimeout (对于所有服务!),大量数据必须通过糟糕的线路传输。 That was the problem I ran into...这就是我遇到的问题......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM