I have a very simple rmi client / server application. I do not use the "rmiregistry" application, although I use it to create a server:
server = new RemoteServer(); registry = LocateRegistry.createRegistry(PORT); registry.bind("RemoteServer", server);
Client side:
registry = LocateRegistry.getRegistry(IPADDRESS, PORT); remote = (IRemoteServer) registry.lookup("RemoteServer");
Here is a fascinating problem: the application works fine when the server and client are running on my (private) local network. As soon as I put the server on a public server, the application freezes for a minute and then causes the following error:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.ConnectException: Connection refused to host: 192.168.xy; nested exception is: java.net.ConnectException: Connection timed out: connect at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) at sun.rmi.transport.Transport$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Unknown Source) at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source ... (the rest is truncated)
The key point that I believe is that the client (working on my private network) cannot connect to itself (my address is 192.168.xy, where xy are some other numbers, but the real error message shows my IP address, indicated there)
If I kill the rmi server on the public Internet, I immediately get the message "connection received to host: abcd"), so I know that something on the server at least works.
Any suggestions?
EDIT: just to make it a little understandable: 192.168.xy is the client address, abcd is the server address. The stack stack indicates that the client cannot connect to the client.
source share