Solved

WCF Faulted Duplex Channel

Posted on 2013-06-20
5
1,614 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now