Hole Punching is a technique to overcome NAT boundaries. To achieve this, the NATed parties have to contact a publicly reachable server. From this server the peers can request the partner’s connection data. Once both peers have got the connection data they simultaneously try to establish a direct connection to each other. The peer’s NAT now considers the incoming request an answer to the own outgoing request and hence does not drop it. Find out more about hole punching at http://www.brynosaurus.com/pub/net/p2pnat/.
Standard Java RMI uses HTTP tunneling to cross firewalls and NAT boundaries. This technique, however, is limited to only a restricted set of network scenarios. In addition, it requires configuration that conflicts with most security policies. We have integrated the hole punching approach described above into Java RMI, providing a light-weight NAT traversal solution for Java RMI. Our solution consists of the following components:
Using Hole Punching RMI is easy as using any other custom socket factories. Just download our custom socket factory and use the class HolePunchingRemoteObject to export your remote objects. See the detailed usage instructions
You also need a publicly reachable mediator server. You can download our implementation and start it with java –jar port. If you omit the port, the default port 8765 will be used.