使用 RMI 检测服务器崩溃

发布于 2024-10-03 10:44:26 字数 287 浏览 1 评论 0原文

我是 Java 和 RMI 的新手,但我正在尝试以有许多客户端连接到单个服务器的方式编写我的应用程序。到目前为止,一切都很好......

但是当我关闭服务器(模拟崩溃或通信问题)时,我的客户端仍然不知道,直到我下次调用服务器。要求我的客户在没有服务器的情况下继续以“离线模式”工作,而且我越早知道自己处于离线状态,用户体验就会越好。

是否存在保持打开状态的活动连接,客户端可以检测到问题或类似问题 - 或者我只需等到下一次调用失败?我想我可以对服务器进行“健康检查”,但看起来这可能不是最好的方法。

感谢您的帮助

I'm new to Java and RMI, but I'm trying to write my app in such a way that there are many clients connecting to a single server. So far, so good....

But when I close the server (simulating a crash or communication issue) my clients remain unaware until I make my next call to the server. It is a requirement that my clients continue to work without the server in an 'offline mode' and the sooner I know that I'm offline the better the user-experience will be.

Is there an active connection that remains open that the client can detect a problem with or something similar - or will I simply have to wait until the next call fails? I figured I could have a 'health-check' ping the server but it seemed like it might not be the best approach.

Thanks for any help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

落在眉间の轻吻 2024-10-10 10:44:26

实际上我只是想了解更多有关 RMI 和 CORBA 的知识,但我还没有你那么远。我所知道的是,这些系统的构建成本也较低,而且据我所知,主动连接是一件昂贵的事情。

我建议您使用一个多播地址,您的服务器以某种方式向该地址发送“我还在这里”,但如果不使用 TCP 连接,UDP 应该足以达到此目的并且更有效。

actually i'm just trying to learn more about RMI and CORBA but i'm not that far as you are. all i know is that those systems are also built to be less expensive, and as far as i know an active conneciton is an expensive thing.

i would suggest you use a multicast address to which your server sends somehow "i'm still here" but without using TCP connections, UDP should be enough for that purpose and more efficient.

风轻花落早 2024-10-10 10:44:26

当我编写 RMI 应用程序(uni 分配)时,我对此进行了一些研究,但我没有遇到任何用于测试远程系统是否处于活动状态的内置功能。我会为此使用 UDP 心跳机制。

I looked into this a bit when I was writing an RMI app (uni assignment) but I didn't come across any inbuilt functionality for testing whether a remote system is alive. I would just use a UDP heartbeat mechanism for this.

鸵鸟症 2024-10-10 10:44:26

(未经测试)。重复对服务器进行单独的 RMI 调用,该调用仅执行“等待 X 秒”然后返回,当服务器关闭时,应该告知执行已失败。

(Untested). Having a separate RMI call repeatedly into the server, which just does a "wait X seconds" and then return, should be told that the execution has failed when the server is brought down.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文