Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to close rmi client safely?
    primarykey
    data
    text
    <p>I want to close all connections between client and server with RMI protocol.</p> <pre><code> Remote r= Naming.lookup("rmi://192.168.105.38:9121/AccountRMIService"); if(r instanceof RmiInvocationWrapper_Stub) { RmiInvocationWrapper_Stub stub = (RmiInvocationWrapper_Stub)r; System.out.println("hashCode="+stub.getRef().hashCode()); } System.out.println(r); //How to close the connection with 'Remote' ? </code></pre> <p>Some code to check rmi status of server:</p> <pre><code>final ThreadLocal&lt;List&lt;Socket&gt;&gt; currentSocket = new ThreadLocal&lt;List&lt;Socket&gt;&gt;() { protected List&lt;Socket&gt; initialValue() { return new ArrayList&lt;Socket&gt;(); } }; RMISocketFactory.setSocketFactory(new RMISocketFactory() { public Socket createSocket(String host, int port) throws IOException { Socket socket = new Socket(host, port); socket.setKeepAlive(true); socket.setSoTimeout(300); currentSocket.get().add(socket); return socket; } public ServerSocket createServerSocket(int port) throws IOException { return new ServerSocket(port); } }); Remote r = Naming.lookup("rmi://192.168.105.38:9121/AccountRMIService"); if (r instanceof RmiInvocationWrapper_Stub) { RmiInvocationWrapper_Stub stub = (RmiInvocationWrapper_Stub) r; System.out.println("hashCode=" + stub.getRef().hashCode()); } Iterator&lt;Socket&gt; s = currentSocket.get().iterator(); while(s.hasNext()) { s.next().close(); s.remove(); } </code></pre> <p>This is not a client for rmi comunication. I just want to check server status using RMI protocol not with simple socket. Sometimes, the server is still running, but all requests blocked.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload