【发布时间】: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