WCF Faulted State Question

I'm calling a WCF service with a windows application. If the service errors (say you throw an exception from the service), it goes into the faulted state and I can't use the proxy anymore for calls.

In light of realizing that your proxy can only fault once, and not wanting to do one of the two things below (from Jeff's post):

  1. Subscribe to the Faulted event of the communication object. 
  2. Check the State property of the communication object before executing a service operation.
I will add option three: 
3. ReInitialize your communication object for every call.


With option three we would be using a static gateway and setting the service channel and proxy back up every time, so at least it would be centrally managed.

I definitely think option two is out the door because we would be checking state before every call and I just don't like the way that it would be implemented.

I do like option one in that it is DRY, but I have others who are not fond of using it. 

Now, with option three, we will incur additional overhead.  Does anyone know how much overhead we would deal with here or what kind of decrease we would see having to recreate the communication object every time?

Print | posted @ Tuesday, October 16, 2007 2:17 PM

Comments on this entry:

Gravatar # re: WCF Faulted State Question
by Victor Bober at 3/18/2008 6:39 AM

Hello Rob,

Well, that is interesting. But there is a case #4 as well, and may be cases #5,6 and so on. Imagine that you have a WCF service and WCF clients of two types. Sometimes a client of type 1 has to communicate with a client of type 2 via your WCF service. One has to implement some asynchronous communication, for example by means of callbacks.

But at that very moment when the client 1is sending a message to the client 2, the proxy of the type 2 has NOT to be in faulted state. Neither client of type 1 nor WCF service can reinitialise the client of type 2. So some mechanism should be implemented to solve this problem when working with callbacks. I implemented my clients sending of 'KeepAlive' message on a regular basis. On sending of the 'Keep Alive' message, the state of proxy is to be checked and the proxy has to be initialized if necessary. (I have to work with my clients in 'per session' mode, no 'singleton' is allowed.)

Does anybody know if there can be better solution, than sending 'KeepAlive' message from clients?

Best regards,
Victor
Gravatar # re: WCF Faulted State Question
by Robz at 3/18/2008 8:56 PM

Hmmmm...sounds like an interesting challenge. Have you talked to Juval Lowy or Michelle Leroux Bustamante about it?

I would consider them the industry experts on WCF.
Gravatar # re: WCF Faulted State Question
by Victor Bober at 3/19/2008 3:21 AM

not yet. i will check their books and post some questions to http://www.dasblonde.net/

I have just found this post in your blog and answered :)

Gravatar # re: WCF Faulted State Question
by Artem at 7/30/2008 2:07 PM

Yeah, its very interesting, like as many writes, i must only turn off property Reliable Sessions and its will be OK at all. So i found that it works only on server, but client lost connection line..Very interesting situations,- if i don't want reliable connection lines, i can realize it normally.)

Your comment:

Title:
Name:
Email:
Website:
 
Italic Underline Blockquote Hyperlink
 
 
Please add 5 and 5 and type the answer here:
 
Twitter