回调中的 Java RMI 超时

发布于 2024-08-28 15:33:43 字数 2051 浏览 5 评论 0原文

我们使用 Java RMI 进行通信。 RMI 客户端将处理请求和带有回调方法的对象传递给 RMI 服务器。服务器在完成处理后调用回调。该设置与RMI 回调中描述的设置类似。

有时,我们在调用回调方法时会在服务器中遇到“读取超时”异常。在引发异常之前,回调线程会停止大约一分钟。

java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is: 
    java.net.SocketTimeoutException: Read timed out
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:286)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:110)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
    at $Proxy2.finished(Unknown Source)
    at com.unrisk.db.grid.GridTask.invokeCallback(com.unrisk.db.grid.GridTask:1292)
    at com.unrisk.db.grid.GridTask.invokeCallbacks(com.unrisk.db.grid.GridTask:1304)
    at com.unrisk.db.service.tasks.EquityMDTask.afterRun(com.unrisk.db.service.tasks.EquityMDTask:276)
    at com.unrisk.db.grid.GridTask.run(com.unrisk.db.grid.GridTask:720)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
    at java.io.DataInputStream.readByte(DataInputStream.java:248)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:228)
    ... 12 more

我们在 Windows Server 2003 32 位下使用 Sun Java JDK 1.6.0_18。

是否可以通过调整 RMI 相关系统属性来解决连接问题?

We are using Java RMI for communication. An RMI client passes a processing request and an object with a callback method to an RMI server. The server invokes the callback when it is done with processing. The setup is similar to the one described in RMI Callbacks.

Occasionally we are getting a "read time out" exception in the server upon invoking the callback method. The callback thread stalls for about a minute before the exception is raised.

java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is: 
    java.net.SocketTimeoutException: Read timed out
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:286)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:110)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
    at $Proxy2.finished(Unknown Source)
    at com.unrisk.db.grid.GridTask.invokeCallback(com.unrisk.db.grid.GridTask:1292)
    at com.unrisk.db.grid.GridTask.invokeCallbacks(com.unrisk.db.grid.GridTask:1304)
    at com.unrisk.db.service.tasks.EquityMDTask.afterRun(com.unrisk.db.service.tasks.EquityMDTask:276)
    at com.unrisk.db.grid.GridTask.run(com.unrisk.db.grid.GridTask:720)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
    at java.io.DataInputStream.readByte(DataInputStream.java:248)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:228)
    ... 12 more

We are using Sun Java JDK 1.6.0_18 under Windows Server 2003 32-bit.

Is it possible to work around the connection problems by tuning RMI related system properties?

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

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

发布评论

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

评论(1

瑕疵 2024-09-04 15:33:43

这篇值得收藏的文章中描述了许多超时:
http://archives. java.sun.com/cgi-bin/wa?A2=ind0208&L=jini-users&P=R27617

在我使用 JRMP 的(有限)经验中,我发现我必须使用 JVM 全局属性来调整读取超时...

题外话:
我的团队现在专门使用 Jeri(Java 可扩展远程调用),它是 Apache River(以前的:Sun Jini)项目的一部分。 Jeri 比 JRMP 更具可配置性,允许您定义自己的底层协议。

A lot of the timeouts are described in this bookmark-worthy post:
http://archives.java.sun.com/cgi-bin/wa?A2=ind0208&L=jini-users&P=R27617

In my (limited) experience with JRMP, I found I had to use JVM-global properties to tweak the read timeouts...

digression:
My team now uses Jeri (Java extensible remote invocation) exclusively, which is part of the Apache River (formerly: Sun Jini) project. Jeri is a lot more configurable than JRMP, allowing you to define your own underlying protocols.

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