WCF two-way HTTP communication to traverse firewalls

I want to use WCF for two way communication without opening a port on the client.

I am developing something like a P2P application (similar to teamviewer / logmein) where you don't need to open ports for communication.

How do I perform two-way communication over HTTP / HTTPS without having to open a port in the client?

Note. Port 80 can be opened on the server ... no problem with that.

thank

+2


source to share


2 answers


It is good that the systems you are talking about work as follows. They first try to force client A and client B to communicate directly with different topologies, which basically require one of them to allow incoming connections, if that fails, they fall back to a third party that acts like a man in the middle. Thus, client A talks to the server and sends messages to it for client B. Then client A receives messages addressed back to it in response. Client B sends his messages to the server and receives a message from client A from the server. Thus, both clients A and B always initiate the connection and do not have to open the port for incoming traffic.

If I understand correctly in your case, you would always like the man in the middle. To do this, you will need to write a WCF service that provides all the relevant methods. For example things like

  • void SendMessageToClient (Guid senderId, Guid recipientId, Message msg)
  • Message [] GetMessages (Guid recipientId)

that is, these methods respectively store and retrieve these message objects from somewhere (like a database or queue or whatever).

Then write a client that connects to the WCF service using HTTP binding and calls methods on the server and processes the results.



Hope you can understand that

  • a) is not a very effective way to communicate.
  • b) that it is difficult to test and debug and understand what is happening since there are so many parties involved and communication is an asynchronous living in three different processes.
  • c) it adds an extra layer on top of the message, so you need to keep it in sight (and preferably in code) when you are dealing with the infrastructure bits and when you are dealing with the actual clientA and clientB protocol that talk to each other in Message objects.

Example pseudo (code)

in this example I am assuming the message object is nothing more than a string and the only command is "whattimeisit" to which the response is the local time in string form

  • ClientA calls server.SendMessageToClient ("clientA", "clientB", "whattimeisit");
  • The server stores this message in the database with ID 1
  • ClientB makes a call to the server GetMessages ("clientB");
  • Server receives message with ID 1
  • ClientB returns a "whattimeisit" response as a response
  • ClientB makes a call to the server .SendMessageToClient ("clientB", "clientA", "19:50:12");
  • The server stores this message in the database with ID 2
  • ClientA calls the server GetMessages ("clientA");
  • Server receives message with ID 2
  • ClientA returns "19:50:12" response as response
+5


source


I'm not sure I understand. The purpose of digital firewalls is (generally) to control communication channels. If you want to communicate bypassing firewalls, you have two options.

  • Hide message from what the firewall allows through
  • Use a communication channel that the firewall does not control.

In the case of the previous one:



You can pass messages to the proxy that passed them on (email is a good, but not entirely responsive example).

In the latter case:

You can put messages in a say file where some other transport layer carries them

+1


source







All Articles