1

I am currently working on a WCF - WSIT integration task. I am using WS-ReliableMessaging with WCF and ws2007HttpBinding.

Reliable session is set up correctly, I am using InstanceContextMode.PerSession and my service instance is killed off after one minute inactivity.

My only concern is that I am not sure how I can create a WCF proxy initialized with an existing OperationContext's SessionId. The Visual Studio generated proxy doesn't seem to accept a SessionId as a constructor, etc.

I would like to be able to reconnect to the active service using the SessionId even if my proxy client died and I had to recreate it.

Jeno Laszlo
  • 2,023
  • 18
  • 36

2 Answers2

1

As I know reliable session in WCF lives only if both client and server are alive. Reliable session is on channel level implemented as WS-ReliableMassaging wich offers transport level reliablity - it means it can handle lost messages, in order delivery, resending messages etc. = reliability is only to overcome unreliable transport protocols like HTTP.

For scenarios where any participant can "die" or go offline you have to use messaging (MSMQ in MS world). When integrating with Java world you will probably need other messaging platform based on JMS.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • Thanks for the quick response. I did some tests and you seem to be right. The sessionId is set during the channel open and no matter how deep I dig I cannot change it. The issue I try to solve here is not error handling, it is related to session management. I hoped that I will be able to disconnect and reconnect my client from a running service. – Jeno Laszlo Mar 22 '11 at 14:09
  • It seems my service instance is alive and running like a headless chicken for a while after my client is disconnected but my client cannot reconnect to it. I guess I will need to use ASP Session or something similar to persist the state of a service state which will mean parsing and reattaching a cookie on the client side. – Jeno Laszlo Mar 22 '11 at 14:10
  • I'm affraid it is not possible. Unhandled exception will terminate the service part so you must open new client proxy if you want to communicate with the service. – Ladislav Mrnka Mar 22 '11 at 14:11
  • Yeah, that’s fine; it seems I cannot reuse the same session id. The only thing I can do is to map the client security details to a ASP.NET session. For example if my client connects using username; my app will need to map the userId to a ASP.NET session and init the instance from it. Another option is to extract the ASP.NET sessionId from the response headers the first time and read the cookie to requests. http://blogs.msdn.com/b/wenlong/archive/2010/02/21/using-asp-net-sessions-from-wcf.aspx – Jeno Laszlo Mar 22 '11 at 14:17
1

you can use durable service

http://www.wcftutorial.net/How-to-Create-Durable-Service.aspx http://blogs.microsoft.co.il/blogs/egady/archive/2008/01/05/wcf-3-5-durable-services.aspx

Annie
  • 670
  • 1
  • 7
  • 20
  • I agree. Persisting the state on the server side will address session management. I will try out the durable service example you mentioned. I think the conclusion of my question is that wsHttp binding based reliable messaging and session relates to communication sessions only; it won’t cover workflow state and disconnected client scenarios out of the box. – Jeno Laszlo Mar 24 '11 at 12:15