回调中的 Java RMI 超时
我们使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这篇值得收藏的文章中描述了许多超时:
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.