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

时间:2012-02-12 15:07:58

标签: wcf silverlight pollingduplexhttpbinding

我有一个带有CallbackContract的WCF服务。使用“pollingDuplexHttpBinding”将服务公开给Silverlight客户端 当Silverlight客户端“死”且服务调用回调操作时,它会在一分钟后收到超时异常。 如何将此超时设置为不同?

谢谢, ELAD

2 个答案:

答案 0 :(得分:0)

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;

更新:在'要使用'How to: Build a Duplex Service for a Silverlight Client'的PollingDuplexHttpBinding'段落下,基于web.config的示例配置PollingDuplexHttpBinding

希望,这会有所帮助。

答案 1 :(得分:0)

所以似乎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>