gpt4 book ai didi

java - 线程 "main"java.rmi.ConnectException : Connection refused to host: 192. 168.1.55 中的异常;嵌套异常是:

转载 作者:行者123 更新时间:2023-11-30 09:23:23 31 4
gpt4 key购买 nike

我在我的系统中运行这段代码,我不想写本地地址(本地主机)或远程地址(IP 地址)...

ref= (RMISIntf)Naming.lookup("rmi://"+"192.168.0.15"+"/RMIServer");

我也尝试这段代码,直到我没有得到回应

 ref= (RMISIntf)Naming.lookup("rmi://"+"localhost"+":"+8033+"/RMIServer");
//MyRemoteObject ro = (MyRemoteObject) Naming.lookup("//" + "localhost" + ":" + port + "/" + name);
//ref=Naming.rebind("rmi://localhost:8080/RmiServer",RMISIntf);

最佳答案

最好先使用本地主机进行测试,因为它很简单,并且不需要像远程连接(即外部地址)那样设置规则。

Java RMI faq说,

The appropriate workaround is to set the system property java.rmi.server.hostname when starting the server. The value of the property should be the externally reachable hostname (or IP address) of the server -- whatever works when specified as the host-part in Naming.lookup is good enough.

还可以查看远程方法调用的属性 here .

关于java - 线程 "main"java.rmi.ConnectException : Connection refused to host: 192. 168.1.55 中的异常;嵌套异常是:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16076509/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com