when I call a method from a RMI Ubuntu client on the OSX server passing an UnicastRemoteObject as parameter, things are super slow. So slow, that eventually, it gets executed but more likely, I get timeout exceptions after like 2-3 minutes. Both machines are in the same network. It’s a freshly installed Ubuntu 12.04. I can telnet from the Ubuntu machine to the OSX one on the used RMI port, so at this point, it doesn’t seem to be a problem. I can also call methods on the server without this UnicastRemoteObject parameter and everything works fine. From OSX to OSX is also fine…
This is, how the server gets started:
LocateRegistry.createRegistry(port);
nodeManager = new NodeManagerImpl(maxConfigurationsPerNode, true);
Registry registry = LocateRegistry.getRegistry(host, port);
registry.rebind("NodeManager", nodeManager);
And this is, how the client connects and calls the method:
Registry registry = LocateRegistry.getRegistry(host, port);
nodeManager = (NodeManager) registry.lookup("NodeManager");
handler = new NodeHandlerImpl();
id = nodeManager.register(handler, id);
NodeHandlerImpl is basically this:
public class NodeHandlerImpl extends UnicastRemoteObject implements NodeHandler {
public NodeHandlerImpl(boolean noSSL) throws RemoteException {
super(0, null, null);
}
....
}
The call to “register” is the one taking ages… NodeHandler extends Remote. When I remove the parameter handler, everything works fine again…
I’m a bit stuck here since a few hours, any clue would be great.
// Edit: Yep, Reverse DNS was the error.
With this hint, I found this site:
http://www.communardo.de/home/techblog/2008/09/17/rmi-kommunikation-zu-remote-hosts-mit-unguenstiger-dns-konfiguration/
So I changed my client connect code to the following and everything was fine:
System.setProperty("java.rmi.server.hostname", host);
Registry registry = LocateRegistry.getRegistry(host, port);
nodeManager = (NodeManager) registry.lookup("NodeManager");
handler = new NodeHandlerImpl();
id = nodeManager.register(handler, id);
This is most likely DNS misconfiguration. Java uses both DNS and reverse DNS. Make sure both are working correctly at both client and server hosts when looking up the other.