views:

291

answers:

3

I have a system in which I need bidirectional communication betwen the client and the server. In some instances the client needs to initiate communication with the server to ask a question, query status, get some data, etc. {We have an AI system that performs repetiative tasks, monitoring, report generation, alerting, etc. and clients apps that allow us to interactive with the server.} In other instances, the server needs to report some change in status or an alert to the client. We're using .NET to implement the system and have looked at a number of different architectures:

A) Open a TCP channel and manage the communications at a low level. This seems to meet our needs but has been rather unstable primarily because our teams lack good experienced in low level communications protocols.

B) Use .NET remoting in which both systems are acting as host - the client registeres the server as a remoting host and once a connection is established, the server goes ahead and registeres the client as a remoting host under a difference channel. This seems to work okay for basic messaging but there are instances in which we need to maintain a "conversation" between the client and the server. Having mutliple clients under this architecture seems to be a bit challenging.

C) Forget bidirectional communication and use a poll architecture to poll the server for new messages - works okay but creates an overly chatty system and makes "conversations" between client and server challenging.

Any thoughs on the best approach? Any different approaches recommended?

A: 

Have a look at Duplex Services in WCF - that might be one way of getting what you need without having to worry about low-level plumbing.

Samuel Jack
A: 

WCF would seem a good choice. There is a rather good tutorial on CodeProject that describes how to implement a client / server chat application.

There is also a series of webcasts here and the book by the same author

Julien Poulin
+1  A: 

I've had good experiences (at "proof of concept" level -- haven't deployed it in production yet) with XMPP as a protocol for such bidirectional communications; while mostly thought of in terms of interactive chat apps, it's actually a general purpose protocol, and it does have .NET implementations. A Microsoft alternative might be MSMQ.

Alex Martelli