I have a self hosted wcf service using net tcp duplex callback
on client side, I listen on faulted event on Channel and ChennelFactory. when the channel faulted, client will recreate channel and re-subscribe.
on server side, I store callback channel and a store a reference of the Channel by calling OperationContext.Current.Channel
so that I can listen on the faulted and closed event on this channel. On faulted, server will remove that subscriber.
This is working most of the time until recently I observed an unexpected behaviour: the callback channel is faulted on server but the channel seems alright on client end, this leads to the client does not re-subscribe while the server already removed that subscriber and client will not receive any callback.
I thought on a duplex communication, if one end sensed fault, the duplex channel should be faulted.
Reliable session is enabled and timeout is very long (2 hours) (maybe this can leads to the client end not sensing fault quick enough?)
Could anybody explain why this is happening?
Another question would be why it is faulted anyway? I have 40 clients connected but the server would detected a random client faulted at a random time.
I am unsure of the reason. But I suppose a channel can fail in a way that the faulted event never reaches the client or server. Also there is the case to consider when a client crashes abrubtly.
Anyway In my project I concluded that relying on faulted channel events is not reliable enough. So I regulary ping all subscribers from the server thru the callback channel. If the client does not reply within the timeout limit, it is removed from the subscribers list.
From the client side you could also catch timeout exceptions and recreate the channel if nessesary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With