views:

781

answers:

3

Hello, What do I use for two way communication over the internet without the necessity to open ports on the client side?

Users won't agree to open ports and do port forwarding on the client side although everything is possible on the server side.

But,I need to accomplish two way communication..

How do I go about achieving this?

It doesn't matter whether its WCF or remoting or webservices... I just need a quick and fast way to just get the concept to work out and distribute the application.

ofcourse,it's going to be through the internet.

Please help.. Thanks

Edit : Please note that i need to connect multiple clients and maintain a session for each client.

+1  A: 

Connect via TCP (raw sockets, or higher implementation) to a your central server.
Your server should have an application that listens to a specific, well known, TCP port.
Each client connects to your server, using the specific port, and "logs in".
Write an application protocol above the TCP (authentication, session management, etc.), and there you have it, since a TCP connection, once established, works for both directions.

Ron Klein
HTTP (using TCP) works in the same way. There's no reason to take such a low-level approach.
Mark Seemann
I think HTTP is expected to have its timeout, and I'm not sure that this limit is OK by the OP.
Ron Klein
In addition, HTTP model is one response per request. I can't tell if the OP wants to "accomplish two way communication" just by single response to a single request.
Ron Klein
+3  A: 

WCF supports duplex HTTP bindings.

As long as the initiating client can access the service, a callback contract can be defined to call the client. It simply keeps the HTTP connection once the client has initiated it.

Mark Seemann
but i think a port has to be opened on the client side and port forwarding is required...right?
Josh
If a client machine can access a web site, it can also receive a response from a web service. The question is simply how much time it takes before the response arrives at the client :) That is what WCF takes advantage of: The client patiently waits for an HTTP response from the service, and it keeps the connection open indefinetely. Since the connection is open, the service can stream responses back to the client whenever it feels like it. The (Azure) Internet Service Bus also works this way.
Mark Seemann
Is there any example for this? I've used WCF like a webservice by adding reference...but how do I make WCF call a function on the client whenever required?
Josh
http://msdn.microsoft.com/en-us/library/system.servicemodel.servicecontractattribute.callbackcontract.aspx
Mark Seemann
There's no config file specified in that binding
Josh
@Josh: I'm not sure I understand whether your latest comment was a question or not. Config files are completely orthogonal to the question about duplex connections.
Mark Seemann
yes,but I don't see the binding specified.That article which you pointed does not show duplex communication taking place through the same port.I want to open only one port for incoming connections on One side.
Josh
Duplex communication is not binding-specific. You can use it with several different bindings. AFAIR, it works with wsHttpBinding (among other bindings).
Mark Seemann
But,will I be able to get this architecture....having a port open for incoming connections only on one side?
Josh
@Josh: That's the idea :)
Mark Seemann
Thanks Mark....but I still feel hard to digest this fact as I've not been able to find any duplex code sample that keeps port open only on the server side. Mostly,every sample specifies a open port on the client for callback
Josh
@Josh: I'm not sure I understand what you mean by keeping a port open on the server side - the server always need to have a port (80?) open - that's the same issue with a normal web server.
Mark Seemann
+2  A: 

It depends what you want to do. Duplex WCF can work, but through NAT and Proxies it becomes somewhat "iffy" because it depends on the client opening a WCF endpoint and maintaining the connection.

I wrote a beginners guide to WCF callbacks a while ago - it's simple enough to do, but you'll need to test it a lot, from various client setups.

blowdart
Does your guide work across NAT?NAT is my problem...I can't expect normal pc users to configure port forwarding.
Josh
please help... any way to get out of NAT?Teamviewer.com and logmein.com have done it....why can't we after having so many technologies inside .Net? There's no out of the box way?
Josh
Firewalls yes, NAT no. You could look at Teredo and tunnelling, but that may be overkill. TeamViewer and Loginme keep a TCP connection open, which tunnels through NAT - that's not WCF, or webservices or remoting (which never plays well with firewalls)
blowdart
That sounds like there are no easy ways.. :(
Josh