Link to home
Start Free TrialLog in
Avatar of odubhgaill
odubhgaillFlag for Ireland

asked on

WCF Faulted Duplex Channel

On my client I am using the DuplexChannelFactory to create a channel to communicate with a WCF service.

On the server I retrieve a callback channel for subsequent use.

Client side:

ICallback callBack = new CallBack();
NetTcpBinding netTcpBinding = new NetTcpBinding(SecurityMode.None); //testing only

DuplexChannelFactory<IService> cf = new DuplexChannelFactory<IService>(callBack,
netTcpBinding,
new EndpointAddress("net.tcp://x.x.x.x:8080/Service"));

channel = cf.CreateChannel();

Open in new window


Server side:

return OperationContext.Current.GetCallbackChannel<ICallback>();

Open in new window


I need to be able to callback from the server over a long period (approx 4 hours).
If I dispose of the channel on the client side can I still use the callback channel on the server side i.e. does the callback channel use/reference the originating client side channel in some way?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of odubhgaill

ASKER

Thanks... thats one of the best articles I've seen on the subject.

I'm confused because on my client the channel is getting disposed once I have registered with the service but the service continues to callback to the client -

Client side:

DuplexChannelFactory<IService> cf = new DuplexChannelFactory<IOcms>(
                                    callBack,
                                    new NetTcpBinding(),
                                    new EndpointAddress("net.tcp://x.x.x.x:8081/Service"));
IService proxy = cf.CreateChannel();

proxy.RegisterService(param1, param2);
                

Open in new window


In the RegisterService method on the server I get a reference to callback object which the service continues to use long after the client object has been disposed.

return OperationContext.Current.GetCallbackChannel<ISomeInterface>();

Open in new window


Any ideas how the service is still able to call back? This looks to suggest that the callback channel is completely seperate from the channel used by the client?
Uhmm, by "execute callback"  do you mean code is still executing code on the client side.
You can still have the callback object defined on the server but without a client to target is doing nothing and must be removed.
The client is still running so the server can callback but the object the client used to connect to the server has been disposed. I thought that the channel the client used to connect to the server was in someway bound with the callback channel the server uses. Maybe that's not the case....
Correct it is not the case, you are better off managing the channel lifetime yourself.