在 ubuntu 笔记本电脑上启动 RMI 服务器
我编写了一个服务器-客户端 rmi 应用程序,并使用 MacOsX 和 Ubuntu 笔记本电脑来测试它们。
当我在 MacOsX 上启动 rmiregistry 和服务器时,我可以在 netstat 中看到端口 1099 已打开并使用的详细信息。 然后,如果我尝试使用 RMI,使用 Ubuntu 笔记本电脑上的客户端 - 它工作正常。
然而,当我尝试相反的事情时: 在Ubuntu上启动rmiregistry和服务器,我在netstat中看不到有关1099端口的任何详细信息。 而且,当使用 Macos 的客户端时,我无法连接到它,并收到以下异常:
Received Exception:
java.rmi.ConnectException: Connection refused to host: 127.0.1.1; nested exception is:
java.net.ConnectException: Operation timed out
发生在 Naming.lookup 发生之后(因此查找顺利,但 RMI 本身不行)。
Ubuntu 上的 rmiregistry 似乎正在将我的客户端重定向到连接 127.0.1.1,而不是服务器的外部 IP,但他拒绝这样做。
可能是什么原因造成的?
I wrote a server-client rmi application and I'm using MacOsX and Ubuntu laptops to test them.
When I start rmiregistry and the server on MacOsX, I can see the details in the netstat that the port 1099 is open and used.
Then If I try to use the RMI, using the client from Ubuntu laptop - it works fine.
However, when I try things the other way around:
Start rmiregistry and the server on Ubuntu, I can't see any details in the netstat about the 1099 port.
And, when using the client from Macos, I can't connect to it, and receive the following exception:
Received Exception:
java.rmi.ConnectException: Connection refused to host: 127.0.1.1; nested exception is:
java.net.ConnectException: Operation timed out
Which happens after the Naming.lookup happened(so the lookup went good, but the RMI itself not).
It seems that rmiregistry on Ubuntu is redirecting my client to connect 127.0.1.1, instead of the external IP of the server, which he refuses to.
What could be the cause of that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了2个解决方案,不知道哪个是正确的:
之后就成功了。但是,我认为拥有静态 IP 地址并不是一个好主意(因为如果它会动态更改怎么办?)
java -Djava.rmi.server.hostname=192.168.1.35 server 192.168.1.35
之后 - 它可以工作。
Found 2 solutions, don't know which is right:
After that it worked. However, I thought that it's not very good idea, to have a static ip-address(because what if it will change dynamically?)
java -Djava.rmi.server.hostname=192.168.1.35 server 192.168.1.35
After that - it works.