【问题标题】:Where or how to configure Service Timeouts?在哪里或如何配置服务超时?
【发布时间】:2014-07-18 09:35:10
【问题描述】:

我有一个 WCF 服务和一个应用程序。

我的应用程序这样调用 wcf 服务:

string endpointAddress = "https:\\mywebsite.com\myservice\service.svc;
WSHttpBinding binding = new WSHttpBinding();
binding.MaxReceivedMessageSize = 524288000;
binding.CloseTimeout = new TimeSpan(0, 0, 20);

EndpointAddress endPointAddress = new EndpointAddress(address);
ChannelFactory<T> client = new ChannelFactory<T>(binding, endPointAddress);
IClientChannel proxy = (IClientChannel)client.CreateChannel();

我的服务的 web.config 文件内容如下:

    <wsHttpBinding>
        <binding name="Secure" maxReceivedMessageSize="10485760" openTimeout="00:10:00" sendTimeout="00:30:00" closeTimeout="00:10:00">
          <readerQuotas maxDepth="10485760" maxStringContentLength="10485760" maxArrayLength="10485760" maxBytesPerRead="10485760" maxNameTableCharCount="10485760" />
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
    </wsHttpBinding>

但我的服务调用在 30 秒后超时。 为什么我的服务调用不使用 Web.config 超时?如果始终使用客户端设置,那么进行 web.config 设置的原因是什么?以及我需要设置哪个 Timeout 属性来停止我的服务调用在 30 秒后超时?

【问题讨论】:

    标签: c# wcf service timeout


    【解决方案1】:

    Using This Link I found that:

    客户端:

    SendTimeout 用于初始化 OperationTimeout,它控制发送消息的整个交互(包括在请求-回复情况下接收回复消息)。从 CallbackContract 方法发送回复消息时,此超时也适用。

    OpenTimeout 和 CloseTimeout 在打开和关闭通道时使用(当没有传递明确的超时值时)。

    没有使用ReceiveTimeout。

    服务器端:

    发送、打开和关闭超时与客户端相同(用于回调)。

    ServiceFramework 层使用ReceiveTimeout 来初始化会话空闲超时。

    所以在这种情况下,我将 SendTimeout 属性设置为 2 分钟。虽然这并不能解释我的 30 秒超时。我感觉这可能与数据库连接超时有关

    【讨论】:

      猜你喜欢
      • 2018-06-16
      • 2020-05-31
      • 2012-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-08
      • 2012-01-29
      相关资源
      最近更新 更多