Thanks all for your answers!
The gest of my problem is the same as this one:
you run server and client on the same computer. Using 127.0.0.1 to start server. Now if client config types in "localhost" instead 127.0.0.1 .... it doesn't connect
localhost and 127.0.0.1 should be equivalent, but they're not... In my case, the server is using what it's thinking are equivalent IP addresses (127.0.1.1 and the IP address it has in the LAN, 192.168.1.131) -- but they're not equivalent if you're connecting from a different machine, so it doesn't work.
K then says:
The only situation to get 127.0.0.1 is if the ethernet cable is unplugged, or no network adapter in the server computer
I don't think we need to deal with these cases, because it's pretty obvious that to connect to the server, the server must be connected to the network. And the power cable must be connected as well. But I have an additional way to get 127.0.0.1 (or actually 127.0.1.1, which is an alternative IP address for localhost). The hostname command returns "paullaptop2". My /etc/hosts file has this line:
127.0.1.1 paullaptop2
The communication goes this way:
- Client says to server port 1099 (the registry): Give me RMI service X
- Server says: It's on IP N port M
- Client says: Connect to IP N port M and access RMI service
The server response "IP N port M" should be the IP of the server on some port that the RMI registry decides. The problem is that the IP of the server on the server itself is 127.0.0.1, which is equivalent to localhost, but of course if you're on a different machine (the client one), localhost is the client machine... Therefore when the client tries to connect to 127.0.0.1 in the last step, this is the machine the client runs on. There is no server there, so it fails to connect.
I think I'm going to add to my design doc that the RMI server must resolve its IP address in a way that is usable by the clients (127.0.0.1 is not, in general). That way I make it a server configuration issue, a prerequisite, so to say. And I'll also add the requirement that there's no firewall, good idea.