title: RMI - work in the same machine, not in LAN
body: <p>I am trying to establish two-communication between one server and two clients. This works very well when all programs run on the same machine but it doesn't work when I try using LAN network.
  I got the error : </p>
  
  <pre><code>java.rmi.ConnectException: Connection refused to host: 192.168.1.24; nested exception is: 
  java.net.ConnectException: Connection timed out: connect
  </code></pre>
  
  <p>Here is the server code :</p>
  
  <pre><code>public class Server{
  private Game partie; // The class Game extends UnicastRemoteObject and implements ServerInterface
  
  
  public Server() throws RemoteException {
      System.setProperty("java.rmi.server.hostname", "192.168.1.24");
      partie = new Game();
      LocateRegistry.createRegistry(1099);
      try{
          Naming.rebind("Server", partie);
      }
      catch(Exception e){
          e.printStackTrace();
      }
  }
  public static void main(String argv[]) throws RemoteException{
      new Server();
  }
  }
  </code></pre>
  
  <p>Here is the constructor of the client code :</p>
  
  <pre><code>public Client(String aName, String aServerAdress) throws RemoteException {
      super();
      name = aName;
      ServerAdress = aServerAdress; //  = "192.168.1.24"
      theRegistry = LocateRegistry.getRegistry(ServerAdress);
  
      try {
          serverInterface = (ServerInterface) theRegistry.lookup("Server");
      } catch (NotBoundException e1) {
          e1.printStackTrace();
      }
  
  
  
      try {
          theRegistry.bind(name, this); // For two-way communication
      } catch (AlreadyBoundException e) {
          e.printStackTrace();
      }
  
  
      serverInterface.registerClient(name);
  }
  </code></pre>
  
  <p>Where registerClient(String name) code is approximately (in Game class) :</p>
  
  <pre><code>cd_client = (ClientInterface) Naming.lookup("rmi://127.0.0.1/" + name);
  </code></pre>
  
  <p>All firewalls are disabled.</p>
  
  <p>I have been working on this problems for many hours and I have still not found  what is wrong. I would really appreciate if you could help me a bit.
  Thank you</p>