【问题标题】:WCF does not terminate call to ClientWCF 不会终止对客户端的调用
【发布时间】:2019-10-26 17:04:03
【问题描述】:

我有一个 WCF 服务的问题,该服务托管在 Azure 中运行 IIS 10 的 Windows 2016 VM 上。

该服务基本上是一个测试服务,我在 operationContract 中放入了一个 Thread.Sleep(计时器),并且持续时间作为 operationContract 中定义的参数发送。

问题是指定最长 4.2 秒的睡眠持续时间运行没有问题,但如果我调用指定 5 秒运行的服务。任务过程在 5 秒后结束,使用上面的代码,内部记录器通知我我已完成但由于某种原因 WCFTestClient 仍在等待响应并继续等待,直到达到配置的超时。在这种情况下,我在服务配置和客户端配置中都有我的 Receive_timeout 和 Send 10 分钟。

作为证据,我在我的网络中创建了一个本地环境,将服务安装在服务器上,在这里经过 5 分钟甚至 9 分钟的测试,测试客户端的行为符合预期。

[OperationContract]
    public void TestServiceTimeout (int timer)
    {
        try
        {
            log.Info("Start test Service");
            System.Threading.Thread.Sleep(timer);
            log.Info("End test srervices");
        }
        catch (Exception ex)
        {
            log.Error($"An error ocurred. Details: {ex.Message}");
            throw;
        }
    }

Web.Config IIS

<binding name="Control.ws.sTest.customBinding0" receiveTimeout="00:20:00" 
        sendTimeout="00:20:00">
      <binaryMessageEncoding />
      <httpTransport />
    </binding>

WCFTestClient 配置

<bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_sFacturacion" sendTimeout="00:10:00" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:60000/ws/sFacturacion.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_sFacturacion"
            contract="sFacturacion" name="BasicHttpBinding_sFacturacion" />
    </client>

【问题讨论】:

  • 如果您在托管 WCF 服务的 VM 上运行 WCFTestClient,您能否重现此问题?

标签: azure wcf virtual-machine


【解决方案1】:

WCF不会主动关闭客户端,即使服务器离线,客户端也会在达到配置的超时时间后捕获通信异常。 请参考下面的超时设置定义。
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/configuring-timeout-values-on-a-binding
如果有什么可以帮助的,请随时告诉我。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-27
    • 1970-01-01
    相关资源
    最近更新 更多