Anonymous - Tue, 24/01/2012 - 04:28

Permalink

I can get RMI working for my local network, however I am bashing my head against the wall trying to get it to work over the internet.

My router port forwards ports 1099, 1100 to 10.10.10.105 (my server's local IP)
I also disable my windows firewall

Here is what my server code looks like:

UserLoginImpl userLog = new UserLoginImpl();
UnicastRemoteObject.unexportObject(userLog, true);
UserLogin stub = (UserLogin) UnicastRemoteObject.exportObject(userLog, 0);
Registry registry = LocateRegistry.createRegistry(1099);
Naming.rebind("//10.10.10.105:1099/UserLogin", stub);

I have -Djava.rmi.server.hostname="server's IP from whatismyip.com" set in the VM Options (I am using Netbeans).

Here is what my client code looks like:

try {
UserLogin stub = (UserLogin)Naming.lookup("//server's IP from whatismyip.com:1099/UserLogin");
}

I get a connection refused error when I attempt to connect with the client. I have been trying to get this to work for the longest time!

CAPTCHA