【问题标题】:WCF and service discovery timeoutWCF 和服务发现超时
【发布时间】:2011-09-01 00:28:28
【问题描述】:

有人知道如何设置发现超时。默认值是10-15s,接缝有点长……

在女巫方面是否必须配置?服务?客户?

服务:

            // Add a ServiceDiscoveryBehavior
            host.Description.Behaviors.Add(new ServiceDiscoveryBehavior());
            // Add a UdpDiscoveryEndpoint
            host.AddServiceEndpoint(new UdpDiscoveryEndpoint());

客户:

    EndpointAddress endPoint = null;

    endPoint = FindCalculatorServiceAddress();

    static EndpointAddress FindCalculatorServiceAddress()
    {
        // Create DiscoveryClient
        DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint());

        // Find IStringReverser endpoints            
        FindResponse findResponse = discoveryClient.Find(new FindCriteria(typeof(IStringReverser)));

        if (findResponse.Endpoints.Count > 0)
        {
            return findResponse.Endpoints[0].Address;
        }
        else
        {
            return null;
        }
    }

提前致谢

【问题讨论】:

  • 顺便说一下,如果您使用带有FindProgressChangedFindCompleted 事件的FindAsync() 方法而不是同步的Find() 方法,则FindProgressChanged 事件会在端点结果进来,这意味着您可以立即访问它们,而不必等待搜索结束。如果您对更多结果不感兴趣,您可以选择执行CancelAsync(),或者让它运行直到超时,此时FindCompleted 触发。

标签: c# wcf service timeout discovery


【解决方案1】:

相信你需要设置 FindCriteria 的 Duration 属性

FindCriteria.Duration Property

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-10
    • 2012-03-23
    • 2010-09-18
    • 2013-01-15
    • 2011-01-14
    • 2010-10-29
    相关资源
    最近更新 更多