【问题标题】:Second wcf polling duplex service call is too long第二个 wcf 轮询双工服务调用太长
【发布时间】:2012-11-08 10:04:59
【问题描述】:

我对 WCF 服务有一个奇怪的问题。我使用 pollingDuplexBinding 和 Silverlight 客户端。 此代码在 web.config 中注册了绑定

<bindingElementExtensions>
   <add name="pollingDuplex" type="System.ServiceModel.Configuration.PollingDuplexElement, System.ServiceModel.PollingDuplex" />
</bindingElementExtensions>

第一次调用一切正常 - 服务快速返回数据。但是第二次调用执行超过 5 次。如果我设置大超时,结果将返回给客户端,否则抛出 TimeoutException。我正在调用的 WCF 方法什么都不做 - 只返回短字符串。

WCF 跟踪说,第二个服务调用仅比客户端调用此方法晚 5 分钟,并且执行速度很快。 我使用这些服务属性:

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

这是客户端代码

        var binding = new PollingDuplexHttpBinding(PollingDuplexMode.SingleMessagePerPoll);            

        var address = new EndpointAddress("/SportService.svc");
        _proxy = new SportDuplexClient(binding, address);

【问题讨论】:

  • 我得到了答案here
  • 你真的需要 AspNetCompatibility 吗?如果否 - 在 web.config 中将其关闭,您也可以调整 sendTimeout 以进行 pollingDuplex bindign

标签: wcf silverlight timeout pollingduplexhttpbinding


【解决方案1】:

我有同样的问题,我是这样解决的:

只需在 web.config 文件中将 aspNetCompatibilityEnabled="false" 设置为 false

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

或在 web.config 中设置 sessionState mode="Off"

<system.web>
    <sessionState mode="Off" />
</system.web>

两种方式我的问题都会解决...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-29
    • 1970-01-01
    • 1970-01-01
    • 2015-04-08
    • 2010-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多