Problem with multiple IP RMI server
843793Mar 9 2005 — edited Mar 10 2005Hi -
I'm having an issue with an RMI server that only comes up when I enable multiple IPs.
The problem is that the client is getting the interface from one IP, but the server is then trying to continue communications to the client on another IP that the client does not have access to.
The client gets the interface to the server, but then when a method call is made it gets an exception saying that the connection timed out, and lists the wrong IP (just some other IP on the server that the client has no knowledge of). Things work fine if the server and client are on the same computer, or if I disable all the other IPs on the server.
I have seen multiple posts on this and tried two solutions, but neither helped.
Solution 1: supply a java.rmi.server.hostname property.
I am creating the registry from within my server (using LocateRegistry.createRegistry) so I set this property from within the code (I have to get the IP at runtime). This property didn't do much for me it seems, things still work when I only have one IP on the machine, but stop working when I have two.
Solution 2: create custom RMI server and client socket factories and pass them to LocateRegistry.createRegistry(port, clientfactory, serverfactory)
This seems to limit the connections to only be accepted on the specified IP, but the client still experiences the time out with the wrong IP if more than one IP exists on the server.
I'll post anything that might help someone solve this issue. I feel that it is bad form on Sun's part to just have the RMI server communicate on whatever IP it feels like and not the one it received the request on (even if they are on different subnets!). This seems like a bug, but I've been told that Sun does not see it that way.
Thanks for any help.
Jason