title: java rmi server hostname
body: <p>I have two RMI java applications: </p>
  
  <p>server</p>
  
  <pre><code>System.setProperty("java.rmi.server.hostname", "0.tcp.ngrok.io");
  System.setProperty("java.security.policy", "security.policy");
  if (System.getSecurityManager() == null) {
      System.setSecurityManager(new SecurityManager());
  }
  
  Registry r = LocateRegistry.createRegistry(1099);
  r.rebind("Calc", new CalculatorImpl());
  </code></pre>
  
  <p>client</p>
  
  <pre><code>System.setProperty("java.rmi.server.hostname", "0.tcp.ngrok.io");
  System.setProperty("java.security.policy", "security.policy");
  Calculator c = (Calculator) Naming.lookup("//0.tcp.ngrok.io:18872"+"/Calc"); 
  int sum = c.add(1, 5);
  </code></pre>
  
  <p>Communication between the two is done with the help of Ngrok:</p>
  
  <pre><code>ngrok tcp 1099
  </code></pre>
  
  <p>result</p>
  
  <pre><code>   Session Status                online
     Account                       nival (Plan: Free)
     Version                       2.2.8
     Region                        United States (us)
     Web Interface                 http://127.0.0.1:4040
     Forwarding                   tcp://0.tcp.ngrok.io:18872 -&gt; localhost:1099
  
     Connections                   ttl     opn     rt1     rt5     p50     p90
                                    5       0       0.00    0.00    5.88    17.03
  </code></pre>
  
  <p>My problem is :</p>
  
  <pre><code> RemoteException
   java.rmi.ConnectException: Connection refused to host: 0.tcp.ngrok.io; nested exception is: 
   java.net.ConnectException: Connection timed out: connect
  </code></pre>
  
  <p>I think the problem is at </p>
  
  <pre><code>System.setProperty("java.rmi.server.hostname","0.tcp.ngrok.io");
  </code></pre>
  
  <p>what should I put on the server and client at <strong>"java.rmi.server.hostname"</strong>?</p>
  
  <p>(Sorry for my bad english)</p>