Trouble connecting to an RMI server which is behind a router
Let's say the public IP of the router is 22.214.171.124
The local IP of the computer with the server is 192.168.0.2
The router is set to forward 126.96.36.199:5678 to 192.168.0.2:5678
In the server I have:
The client has:
System.setProperty( "java.rmi.server.hostname" , "188.8.131.52" );
Registry registry = LocateRegistry.createRegistry( 5678 );
registry.rebind( "TheWebServer" , webServerInt );
When client is on the network local to the server it's ok. When the client is outside the local network it gets java.rmi.ConnectException: Connection refused to host: 192.168.0.2;
Registry registry = LocateRegistry.getRegistry( "184.108.40.206" , 5678 );
server = (WebServerInterface) registry.lookup( "TheWebServer" );
Obviously the server is giving the client the IP of 192.168.0.2 as it doesn't appear in the code, which I thought
System.setProperty( "java.rmi.server.hostname" , "220.127.116.11" ); was supposed to change.
Any input would be greatly appreciated.