[英]Can't connect two remote hosts in Java RMI
我的服務器代碼如下:
Registry r = java.rmi.registry.LocateRegistry.createRegistry(1399);
r.rebind("Chat", new IRC());
我客戶的代碼是
IRCInterface remoteObject = (IRCInterface) Naming.lookup("rmi://localhost:1399/Chat");
String history = remoteObject.read();
在本地主機上,它可以正常工作,但是我無法連接兩台遠程計算機(主機)。 我已關閉所有防火牆。
怎么了?
控制台輸出:
Error: java.rmi.ConnectException: Connection refused to host: 150.254.79.20; nested exception is:
java.net.ConnectException: Connection timed out: connect
Naming.lookup("rmi://localhost:1399/Chat");
上面查找中的localhost
應該替換為remotehost IP(或)計算機名稱。 否則,查找僅在本地計算機上發生。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.