0

I am creating a WCF client channel using DuplexChannelFactory rather than a generated proxy.

For a particular method, I am throwing a known FaultException<MyFault> on the server side. I have marked up the service interface with [FaultContract(typeof(MyFault))]as required.

On the client side, I catch this FaultException<MyFault> and display an error.

All this works absolutely fine, but for some reason WCF is retrying the service call 5 times before returning control to my client code. This is causing a noticeable delay on the client.

The debugger breaks 5 times on the service call in my client code before proceeding to the next line of my code. I cannot step into it, but the call stack shows the exception being thrown deep within WCF.

A breakpoint on the service side only fires once.

The channel is not faulted once control returns to me.

Debugger output shows:

A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in MyService.dll

Additional information: Fault Test

A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in System.ServiceModel.dll

Additional information: Fault Test

A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in System.ServiceModel.dll

Additional information: Fault Test

A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in System.ServiceModel.dll

Additional information: Fault Test

A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in System.ServiceModel.dll

Additional information: Fault Test

A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in mscorlib.dll

Additional information: Fault Test

Is this normal behaviour? Why is WCF retrying when I am returning a known expected fault?

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
GazTheDestroyer
  • 20,722
  • 9
  • 70
  • 103
  • Are you using a reliable session? I ask this because I am thinking about the MaxRetryCount property from the reliableSession which is available when you use a custom binding. – lex87 Aug 13 '12 at 13:57
  • Thanks for the suggestion. I am using named pipes, so yeah I get reliable sessions implicitly. Having looked at the docs for MaxRetryCount is appears the default is 8 rather than 5 though, and I'm not setting it anywhere. The doubling of the timeout seems interesting though, as I was wondering how even with 5 calls it was slow enough to be noticeable. – GazTheDestroyer Aug 13 '12 at 15:30
  • The first exception is probably a FaultException. Are you sure that all the additional exceptions really are of that type and not something else? This isn't normal but you'll probably have to post some code and a config if you want us to do more than guess. – ErnieL Aug 13 '12 at 15:36

0 Answers0