check java.rmi.Remote client alive?

Hi,

I have a Client program which extends java.rmi.Remote and a Server program which has a method Connect(java.rmi.Remote client).

in my Server program, I add the "java.rmi.Remote client" stub reference into a vector when any client calls the remote method Connect(java.rmi.Remote client).

when I am trying to check if the client is still alive, how could i make use of the stub reference to do so? I have check if the reference is null but it doesn't work.

Thank you for any help.

[513 byte] By [eddy_nypa] at [2007-10-2 20:02:40]
# 1
If the client has a method that can be called - even if the method does nothing - then there will be an error thrown if the cient cannot be contacted.
bschauwejavaa at 2007-7-13 22:42:37 > top of Java-index,Core,Core APIs...
# 2

I have a callback method to send the client message but it is not appropriate to send blank text to check if client is still alive as this may confuse the clients.

Also I am constraint to the callback interface which only have a method to send message to client.

Do I need to do socket programming?

Hope that you could help. Thanks alot

eddy_nypa at 2007-7-13 22:42:37 > top of Java-index,Core,Core APIs...
# 3

Forget about checking whether the client is still alive separately from calling it. Just try to call your method when you have a reason to do so: if it fails, the client isn't there any more. There is no more reliable technique in RMI or anything else: no means by which you check liveness can guarantee that the next remote call will work, so just take success or failure of the next remote call as your indicator.

See also http://forum.java.sun.com/thread.jspa?threadID=736033

ejpa at 2007-7-13 22:42:37 > top of Java-index,Core,Core APIs...
# 4

I am checking on the client without client knowing it. i need to use this when any of the client call my server method to shut down.

i will need to check that no client are connected or alive before shutting down the server. this is why the operation have to be transparent to all other client.

Yet i could not change the callback interface as it has been published and there are all sort of clients connecting to the server using this interface.

Probably could I achieve that using socket connection ?

i would appreciate if someone could suggest a solution to it. Thank you.

Message was edited by:

eddy_nyp

eddy_nypa at 2007-7-13 22:42:37 > top of Java-index,Core,Core APIs...
# 5
Well there is really no such thing as 'connected' in RMI. You need to clarify (to yourself) what you mean by this.UnicastRemoteObject.unexportObject(obj,false) will fail (return false) if any remote calls are currently in progress.
ejpa at 2007-7-13 22:42:37 > top of Java-index,Core,Core APIs...