Solved

WCF Faulted Duplex Channel

Posted on 2013-06-20
5
1,715 Views
Last Modified: 2013-06-21
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
0
Comment
Question by:odubhgaill
  • 3
  • 2
5 Comments
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 39265101
Uhmm,  the answer is yes, your server will register an entry to communicate with your client, thus client program must keep the channel reference for the callback to work properly, other wise the server does not know how to contact your client program.

I used the sample shown on the link below to build a system before as it gives me more visibility of connecting/disconnecting clients:
http://www.devx.com/dotnet/Article/38814
0
 

Author Comment

by:odubhgaill
ID: 39266435
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?
0
 
LVL 35

Expert Comment

by:Miguel Oz
ID: 39267218
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.
0
 

Author Comment

by:odubhgaill
ID: 39267299
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....
0
 
LVL 35

Expert Comment

by:Miguel Oz
ID: 39267486
Correct it is not the case, you are better off managing the channel lifetime yourself.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question