Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is WCF Duplex a good choice?

Tags:

wcf

duplex

After developing mini project with WCF duplex (Chat Service | Sms Service), I got a Point that maybe not be correct!!

I believed Duplex theory is good and useful but there is a lot problem about using Wcf Duplex. (like reliable session, Time-out exceptions, Client address-Management on server side, proxy management on Client Side)

am I think wrong ? am I miss something?

For more Information I Used wsDualHttpBinding not tcpBinding.

like image 989
Rev Avatar asked Mar 02 '11 10:03

Rev


People also ask

When would you use duplex WCF service?

A duplex contract consists of two one-way contracts between the client and the server and does not require that the method calls be correlated. Use this kind of contract when your service must query the client for more information or explicitly raise events on the client.

How WCF duplex works?

Duplex communication occurs when a client connects to a service and provides the service with a channel on which the service can send messages back to the client. Note that the event-like behavior of duplex services only works within a session. To create a duplex contract you create a pair of interfaces.

Which HTTP binding is used for duplex contracts?

This is the WsDualHttpBinding. This binding is designed for use with Duplex Service contracts, which allows both the Services and clients to send and receive the messages.


1 Answers

If you need bidirectional communication and you want to use WCF, duplex channels are the way to go. You just need to design your application correctly and correctly handle all problems you have described. If you feel that these problems are overhead and make things even worse you can always use network programming directly (sockets) or handle bidirectional communication by yourselves exposing separate service on server and another on client (where first call from client inform server about clients address) - this scenario will suffer from the same communication problems as WsDualHttpBinding.

WsDualHttpBinding itself is special kind of duplex communication. I personally don't like it because people very often misuse it. The problem is that this binding uses two separate connections - one from client to server and second from server to client. That is big difference to net.tcp where only connection initiated from client to server is used. Obviously using WsDualHttpBinding over internet (= you don't have control over client machines) becomes much more complicated because each client must configure its firewall (in computer, on home internet gateway, etc.) to allow connection on some port. Also if you want to run more then one instance of application on the same client machine, each instance must use its own port.

like image 92
Ladislav Mrnka Avatar answered Oct 06 '22 00:10

Ladislav Mrnka