gpt4 book ai didi

wcf - 更改 WCF 默认超时

转载 作者:行者123 更新时间:2023-12-05 00:07:17 24 4
gpt4 key购买 nike

我这里有一个 WCF 双工服务,要求是对客户端的回调应该有 10 秒的超时,因此我的服务的 web.config 文件如下所示:

        <bindings>
<basicHttpBinding>
<binding name="simulatorEndpoint" closeTimeout="00:00:10" openTimeout="00:00:10"
receiveTimeout="00:00:10" sendTimeout="00:00:10" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">

<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<wsDualHttpBinding>
<binding name="wsdualEndpoint" closeTimeout="00:00:10" openTimeout="00:00:10"
receiveTimeout="00:00:10" sendTimeout="00:00:10" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" clientBaseAddress="http://localhost:1235"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:00:10" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>

在客户端,app.config 文件中的绑定(bind)具有相同的超时值。

现在的效果是,如果客户端向服务器发送请求,则超时为 10 秒。但另一方面,如果服务向客户端发送回调,则超时为 1 分钟。这很奇怪......显然超时是在客户端正确设置的......但不是在服务上......我怎样才能更改服务的超时?

PS:我正在使用 Visual Studio 2010 及其 Debug模式和适当的 ASP.NET 开发服务器 10.0.0.0

最佳答案

binding timeouts的简要总结...

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.


[编辑:一些代码]
也尝试将此添加到您的服务配置中
<behaviors>
<endpointBehaviors>
<behavior name="MyCallbackBehavior">
<callbackTimeouts transactionTimeout="00:00:10"/>
</behavior>
</endpointBehaviors>
<behaviors>

然后将行为添加到您的端点
<endpoint behaviorConfiguration="MyCallbackBehavior" />

关于wcf - 更改 WCF 默认超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2236909/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com