我有一个带有CallbackContract的WCF服务。该服务使用"pollingDuplexHttpBinding"公开给Silverlight客户端当Silverlight客户端"死"并且服务调用回调操作时,一分钟后会出现超时异常。如何将此超时设置为不同的?
谢谢,Elad
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;
更新:在"如何:为Silverlight客户端构建双工服务"的"使用PollingDuplexHttpBinding"段落中,有一个基于web.config
的配置PollingDuplexHttpBinding
的示例。
希望,这会有所帮助。
所以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>