Silverlight Tip: Problems with polling duplex inactivitytimeout.

 Many people ask question why polling duplex session shutdown after 10 minutes in spite of polling duplex InactivityTimeout value is more than hour.

In private email Christopher Scrosati (Silverlight WS Team) told me that I've also should configure ReciveTimout.

Here is the code sample, which shows how to configure polling duplex correctly:

HttpTransportBindingElement http = new HttpTransportBindingElement();

BinaryMessageEncodingBindingElement binary = new BinaryMessageEncodingBindingElement();

PollingDuplexBindingElement polling = new PollingDuplexBindingElement();

polling.InactivityTimeout = TimeSpan.FromHours(1);

CustomBinding binding = new CustomBinding(polling, binary, http);

binding.ReceiveTimeout = TimeSpan.FromHours(1);

Hope it helps! Many thanks to Christopher =)

 

11 Comments

  • Great posts.Just keep going good work.
    Polling duplex is hot subject these days...

  • Thanks Zec, Soon I'm going to experiment with SL socket and make some kind of comparison, because of many colleagues say that sockets are much faster.

  • How does the timeout work? If the client is alive and responding, it shouldn't ever time out, right ? Or am I wrong, is the session basically only good for whatever duration you set at the beginning?

    Is there a way on the client side to determine if you've been timed out and to reconnect ?

  • cool.. It worked. btw, I put ReceiveTimeout on PollingDuplexHttpBinding, and it's working fine..

    PollingDuplexHttpBinding polling = new PollingDuplexHttpBinding();
    polling.InactivityTimeout = TimeSpan.FromHours(1);
    polling.ReceiveTimeout = TimeSpan.FromHours(1);

    btw, How can I put it in infinite loop?

  • Hi there,

    I wrote a WCF server which generates a number each second (selfhosting console application). I sucessfully connected my silverlight 4 app to it and display the number the server pushes to the callback. This works for 10 minutes, afterwards client and server stop to produce/display any further numbers. I set the InactivityTimeout AND the ReceiveTimeout on the client side. It doesn't affect the timeout, though. Can anybody provide a working example where a silverlight client really gets updates after 10 minutes? Or do I have to set these timeouts on the server side? How can I do this in the config file?

    Regards,

    Stefan

  • @Stefan:

    I believe the PollingDuplexHttpBinding.InactivityTimeout and .ReceiveTimeout properties need to be set on both the client- and server-side bindings. I can increase the length of time (10 mins default) before which the duplex messages stop (by increasing the properties mentioned above), but I don't understand why it times-out at all since our server-side code is sending a message every 30 seconds.

    Regards,
    Scott

  • I was able to have it run for more that ten minutes by setting three different parameters to the following:
    var binding = new PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll);
    binding.ReceiveTimeout = TimeSpan.MaxValue;
    binding.InactivityTimeout = new TimeSpan(24,0,0,0); //maximum is 24 days
    and in the web.config file I changed serverPollTimeout="Infinite".

  • I agree with Scott Edmondson too, Do you find any other solution?
    Regards
    scott

  • Finaly we've made it working after many hours of problems. The only way it is working is after client bindings time outs are increased, and configuration in Web.config is proper with set both inactivity and receive timeouts.
    example in Web.config:
    ...




    ...

  • hi,i am harshal
    i am also facing such kind of issue with duplex binding,its such a big issue that i am facing ever.

  • I am getting w3wp error on the server where service is installed... this service throws exception and its not available for some duration... after sometime it work perfectly for 10-15 and repeates above problem... this is really paathetic...

Comments have been disabled for this content.