Hi everyone,

I am having some troubles setting up client timeouts with Java RMI. My application consists of one client (from now on C), which conects to some server (CS), and that server also acts as a client for many other servers (Si). The problem comes when the client C wants to access the remote method from CS. Because is a remote method, you can not be sure that is going to reply soon (if it even does it at all) so I want to set a timeout on the client side. I did not found anything in Java RMI except from this:

Java Code:
System.setProperty("sun.rmi.transport.tcp.responseTimeout", "10000");
It is undocumented but it works, making that if the method takes longer than 10 seconds, then the client gets an exception.

The real problem comes when I want to do the same for the CS, when it behaves like a client for the servers Si. Because I have more than one, I implemented it using threads, so the requests can be proccesed in parallel. First I tried to do the timeout in the same way, but I do not get any exception if the remote method from S takes more time. After that, I tried just waiting manually like this:

Java Code:
      while ((threads.activeCount() > 0) && flag) {
         if (t1-t0>5000){
            flag = false;
where threads is a group with all the threads, but I am facing some problems if the time runs out, because I have to kill the threads, but they are blocked in some input operation (the call to the remote method) and interrupting them has no effect. I have read that I have to close the socket connection, but because RMI hides all that stuff I have no idea of how to do that. I will appreciate any suggestions on how to solve this problem. Thanks in advance.