2

I have a WCF server which maintains a reference to a client callback using a duplex model.

If I explicitly close the callback connection on the server:

ICallBack callBack = OperationContext.Current.GetCallbackChannel<ICallBack>();
callBack.Close()

The client fails to receive notification of this event through subscribing to either of:

client.InnerChannel.Closed += Handler;
client.InnerDuplexChannel.Closed += Handler;

Neither event handler is executed.

However, if I change the callback to an Abort instead of a Close on the server-side, the client receives notification of the Faulted handler and then subsequently the Closed handler. So aborting works as expected.

I've checked the callback is in a valid state so why is it the client is receiving the Faulted notification on Abort and NOT the Closing notification on Close? The state of the callback after Close is Closed.

As per the MSDN documentation gracefully closing the callback connection using Close would be my preferred choice over the more abrupt Abort.

user978139
  • 579
  • 4
  • 16

1 Answers1

1

because you're casting that to your own interface, which I assume implements Close( ), which is not something that will fire a WCF event.

You need to do this:

IClientChannel pClientChannel = (IClientChannel) callback;
pClientChannel.Close();

that's simplified. You really should do the try/catch Close/Abort pattern. If close doesn't work, call abort on it.

eric frazer
  • 1,492
  • 1
  • 12
  • 19