0

I have an RMI Server with remote clients connecting wirelessly. All is well until the wireless connection is severed. My RMI Server detects it has not received a ping from the client and executes a ping to client that throws an exception which I then handle. The problem is it takes approx 25 seconds for this exception to be thrown, as a result the RMI Server does not respond to any requests from other connected clients until the Exception is thrown.

I have been searching for several days, have set properties on both client and server as connectionTimeout, responseTimeout, disableHttp, without success. Hope some one can help point me in the direction to sure up my networking.

user207421
  • 305,947
  • 44
  • 307
  • 483
MAB
  • 121
  • 3

1 Answers1

0

The only Sun RMI system properties relevant to this are sun.rmi.transport.tcp.responseTimeout and maybe sun.rmi.transport.tcp.readTimeout, which you need to set before exporting any remote objects.

However I question your diagnosis. Neither the RMI runtime system nor RMI servers are single-threaded, so the 25 second delay won't hold up other clients.

So if you're experiencing client stalls it isn't RMI's fault. Possibly it is the network stack misbehaving.

I further question your entire strategy. RMI uses connection pools, not permanent connections: the idea of pinging the server and the client goes entirely against the RMI philosophy, and wastes connections. I would get rid of all these pings, and just deal with java.rmi.ConnectExceptions as and when and if they arise. You can control the connection lifetimes a bit via other system properties on that page.

If you're looking for a solution to detect vanished clients, there are much better ones: see this answer and this one.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • My client executes a remote method on the server to inform the client is connected to the server. I appreciate your taking the time to provide feedback. Can you point me in the direction of a robust RMI client/server handshake example to advise the client when the server is no longer connected in a reasonable time frame like 30 seconds? – MAB May 26 '17 at 14:01
  • The client *isn't* connected to the server, except for the duration of the remote call and however long the connection pool persists the connection after that. RMI deliberately conceals the TCP connection from you, so it isn't proper or meaningful to talk about clients or servers being connected. Have a search here for the Remote Session pattern, and using the `Unreferenced` interface to detect client 'disconnect'. – user207421 May 26 '17 at 23:32
  • 1
    Most appreciated, Just ordered your book, you have a most impressive resume, Hope people for whom you correspond with appreciate the advice and straight to the point support you provide. – MAB May 28 '17 at 16:24
  • @MAB Thank you very much. – user207421 May 28 '17 at 23:54
  • I received your book today and ask if there is a working site to download the code and or any complete examples of a Sessions based Server? the link in the book does not work www.aw.com/cseng/titles/0-20170043-3 – MAB Jun 02 '17 at 18:59
  • @MAB You can download it from [here](http://rmiproxy.com/javarmi/javarmi.zip). I hadn't updated that since 2001 and there were some changes, I've updated the zip and the [Javadoc](http://rmiproxy.com/javarmi/javadoc). – user207421 Jun 05 '17 at 00:58