简体   繁体   English

设置轮询双工WCF服务中的回调超时

[英]Set the Timeout of a Callback in a Polling Duplex WCF Service

I have a WCF service with a CallbackContract. 我有一个带有CallbackContract的WCF服务。 The service is exposed to a Silverlight client using "pollingDuplexHttpBinding" When the Silverlight client is "dead" and the service calls a callback operation, it gets a timeout exception after one minute. 该服务使用“ pollingDuplexHttpBinding”公开给Silverlight客户端。当Silverlight客户端为“ dead”且该服务调用回调操作时,一分钟后将收到超时异常。 How can I set this timeout to be different? 我该如何设置不同的超时时间?

Thanks, Elad 谢谢,埃拉德

There is a nice article in MSDN related to configuring PollingDuplexHttpBinding : MSDN中有一篇不错的文章,与配置PollingDuplexHttpBinding有关

//Inactivity timeout
PollingDuplexHttpBinding binding = new PollingDuplexHttpBinding();    
//Get default inactivity timeout
TimeSpan defaultInactivityTimeOut = binding.InactivityTimeout;
//Returns default timeout in minutes: 10
string txtDefaultInactivityTimeOut = defaultInactivityTimeOut.Minutes.ToString();    
//Set new inactivity timeout
TimeSpan newInactivityTimeOut = new TimeSpan(0, 5, 0);
binding.InactivityTimeout = newInactivityTimeOut;

UPDATE : Under 'To use PollingDuplexHttpBinding' paragraph of ' How to: Build a Duplex Service for a Silverlight Client ' there is web.config based example configuring PollingDuplexHttpBinding . 更新 :在 如何:为Silverlight客户端构建双工服务 的“ 使用PollingDuplexHttpBinding”段落下,有一个基于web.config的示例,该示例配置PollingDuplexHttpBinding

Hope, this will help. 希望这会有所帮助。

So it seems that the "SendTimeout" attribute of PollingDuplexHttpBinding does the job: 因此,似乎PollingDuplexHttpBinding的“ SendTimeout”属性可以完成此工作:

<extensions>
  <bindingExtensions>
    <add name="pollingDuplexHttpBinding" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement, System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </bindingExtensions>
</extensions>

<bindings>

  <pollingDuplexHttpBinding>
    <binding name="myPollingDuplex" sendTimeout="00:00:05"/>
  </pollingDuplexHttpBinding>

</bindings>


<services>
  <service name="Kodak.Pgy.Server.Event.WCFService.EventService" behaviorConfiguration="EventBehavior">

    <!--For duplex communication with the service from silverlight client-->
    <endpoint address="/for-silverlight" binding="pollingDuplexHttpBinding" bindingConfiguration="myPollingDuplex" contract="IEventService"/>

  </service>

</services>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM