Domanda

I want to send a message between two java applications that are both behind different firewalls. Is there a way to do this without port forwarding?(for example p2p, what is skype doing?)

È stato utile?

Soluzione 2

There is no way to do it without port forwarding on at least one of the firewalls (assuming the firewalls have appropriately restricted rules.

With TCP there's a server, and a client. The server will accept connections, and it cannot accept requests until the firewall in front of the server forwards the network traffic to it.

Typical client-side firewalls allow outgoing requests to remote servers (sometimes limited to certain services like http and https, etc.).

So, the firewall on the server-side of the network will need to be configured to forward appropriate packets to the actual server machine.

Things like skype often only have outgoing connections (they do not run server sockets waiting to connect), but instead connect to a central server which then routes the traffic for the system. VPN's are often done this way.

Other protocols like most P2P protocols require that the peer runs a port, and the firewall needs to be configured to forward the traffic to the peer.

In the past number of years a protocol called Internet Gateway Device Protocol (normally branded as "UPnP") has been established which allows peers to request that the firewall forward the traffic on a request basis. Most bittorrent clients will allow you to use UPnP to reconfigure your firewall, and most modern residential-type broadband routers will support these requests.

So, the firewall needs to be reconfigured, but there are ways to get your server software to ask the firewall to do the reconfiguring 'automatically'

Altri suggerimenti

There is nearly no way to do this, but after really much searching, i've found a way that works quite often. It is called UDP-Punching.

It works with TCP, too, but not that good as with UDP.

https://en.wikipedia.org/wiki/UDP_hole_punching (in java you can do it with DatagramSocket)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top