Set the Timeout of a Callback in a Polling Duplex WCF Service
-
29-04-2021 - |
Question
I have a WCF service with a CallbackContract. 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. How can I set this timeout to be different?
Thanks, Elad
Solution 2
So it seems that the "SendTimeout" attribute of PollingDuplexHttpBinding does the job:
<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>
OTHER TIPS
There is a nice article in MSDN related to configuring 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
.
Hope, this will help.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow