Running RMI server on ubuntu laptop
I wrote an rmi server-client application and I am using MacOSX and Ubuntu to test them.
When I run rmiregistry and the server on MacOsX, I can see the details in netstat that port 1099 is open and in use. Then if I try to use RMI using a client from Ubuntu laptop - it works fine.
However, when I try things differently: Start rmiregistry and the server on Ubuntu, I don't see any details in netstat about port 1099. And when using a client from Macos, I cannot connect to it and get the following exception:
Received Exception:
java.rmi.ConnectException: Connection refused to host: 127.0.1.1; nested exception is:
java.net.ConnectException: Operation timed out
What happens after the Naming.lookup happened (so the search went well, but the RMI itself was not).
It seems that rmiregistry on Ubuntu is redirecting my client to connect 127.0.1.1 instead of the external IP server it refuses to.
What could be causing this?
source to share
Found 2 solutions, don't know which is correct:
- I checked / etc / hosts on the Ubuntu machine and saw that 127.0.1.1 was mapped to the name ubuntu-laptop, so I rewrote it to the correct external IP.
After that, it worked. However, I thought it was not a good idea to have a static ip address (because what if it changes dynamically?)
- A workaround for this problem is to specify the hostname when starting the server using the rmi.server.hostname property. So it would be something like this:
java -Djava.rmi.server.hostname=192.168.1.35 server 192.168.1.35
After that, it works.
source to share