I持つ2つのRMIのJavaアプリケーション:のJava RMIサーバのホスト名
ngrok tcp 1099
:2の間の通信がNgrokの助けを借りて行われ
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);
サーバー
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());
クライアント
結果
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 -> localhost:1099
Connections ttl opn rt1 rt5 p50 p90
5 0 0.00 0.00 5.88 17.03
私の問題は、次のとおりです。
RemoteException
java.rmi.ConnectException: Connection refused to host: 0.tcp.ngrok.io; nested exception is:
java.net.ConnectException: Connection timed out: connect
私は、問題は、私は「java.rmi.server.hostnameで、サーバーとクライアントに置くべきか
System.setProperty("java.rmi.server.hostname","0.tcp.ngrok.io");
であると思います"? (私の悪い英語のため申し訳ありませんが)
一般に