Closing a session with PollingDuplexHttpBinding

665 views Asked by At

I'm using the WCF PollingDuplexHttpBinding channel to push notifications to Silverlight clients. For the most part it works well but I'm fighting it to get a few basis session management functions to work properly.

The biggest problem I've got is trying to let the server know the client has finished with a session and no longer requires any notifications. The CloseAsync call on the client stops the client side of the channel from sending requests for new notifications for that session only and it also sends a CloseSession SOAP request to the server. The problem is the server side of the channel sends back a 404 saying it doesn't recognise the CloseSession action. As far as I can see that error is from the internals of the PollingDuplexHttpBinding channel and doesn't make it up to the application so that the session closure can be properly taken care of.

Has anyone else come across this issue and perhaps found a way around it?

2

There are 2 answers

0
sipsorcery On BEST ANSWER

Can't be done by the looks, Gripes on PollingDuplexHttpBinding.

0
absolutdeno On

Well that gripe article was just awesome, and indirectly solved a related problem I've been having with Silverlight working very slowly when doing Duplex over HTTP. Bsaically, the problem is caused by having ASP.Net Session State turned on in the website and using Silverlight's BroserHttp stack (instead of ClientHttp stack).

Yavor does a good job (in this article) of explaining the problem:

http://blogs.msdn.com/b/silverlightws/archive/2009/09/30/having-a-pollingduplex-service-and-any-other-wcf-service-in-the-same-website-causes-silverlight-calls-to-be-slow.aspx

The simple fix, if you're having this issue is to register a route for the ClientHttp stack before invoking your service. This can be accomplished simply by calling:

WebRequest.RegisterPrefix(requestUri.AbsoluteUri, WebRequestCreator.ClientHttp);

Where requestUri is a Uri of your service. Hope this helps.