I have an rmi server on a box with two public interfaces. When a client connects, it always returns the wrong ip address in the UnicastServerRef2 [liveRef: [endpoint:[192.x.x.x:xxxx
.... The connection from the client goes to the other interface with ip 10.x.x.x
. Does anybody know how to solve this? I do not want to specify the ip when binding the stub. It works then, but I would like it to listen on all interfaces (0.0.0.0
).
If I specify java.rmi.server.hostname=myhostname
and use a RMIServerSocketFactory
to create a ServerSocket[addr=myhostname/10.x.x.x,localport=xxxx]
, it still returns the 192.x.x.x
adress to the client as remote endpoint. Weird enough I have two UnicastRemoteObjects
objects on diffrerent ports and one of them returns the right address, the other not.
Any Ideas how to make it to return the endpoint with the ip of the interface the connection was made to?
That's what the java.rmi.server.hostname property is for. Set it at the exporting JVM to whatever IP address you want the clients to use to connect to it.