aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RMI timeout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "RMI timeout" Watch "RMI timeout" New topic
Author

RMI timeout

Yemi Dalley
Greenhorn

Joined: May 03, 2007
Posts: 12

Hello all,

I'm rounding off my URLyBird assignment but i've noticed that the client just waits forever whenever the server is no longer unavailable. Is there a way to set a time out, after which the proxy throws an appropriate exception ?

Thanks


SCJD (URlybird)
Alex Belisle Turcot
Ranch Hand

Joined: Apr 26, 2005
Posts: 516
Hi,

I'm at work and can't try it.. but you got me thinking and wanted to know for myself, and I found this :

RMI Naming.loookup timeouts

Could you please tell me if that solved the problem ?

Regards,
Alex
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Originally posted by Alex Belisle Turcot:

RMI Naming.loookup timeouts


I dont think Naming.lookup will hang forever if the server is not available.
If i understand you correctly, then what you require is that if a method call does not complete within a stipulated time period, it should throw an exception. If this is what you are referring to then, you need to write your own RmiClientSocketFactory and set the socket timeout to a desired value for every socket created.
The following code may help:



This link will also help.


apigee, a better way to API!
Musab Al-Rawi
Ranch Hand

Joined: Aug 06, 2007
Posts: 231
hi,

Although this sounds very interesting but don't you think that this is not part of the requirements.
if it not part of the your requirements consider my humble advice of leaving this part till the end after you make sure that everything required is working perfectly.


SCBCD - SCWCD - SCJD - SCJP - OCA
Yemi Dalley
Greenhorn

Joined: May 03, 2007
Posts: 12

thanks guys ;
It's very interesting indeed ..
my problem was because i didn't unexportObject the remote object , i only called unbind.

After calling unexportObject the default timeout seems to be ok.
Fors Judd
Greenhorn

Joined: Mar 26, 2012
Posts: 6
Thanks for the careful and complete piece of code.
But due to my own mountainous confusion, I do not see when or where to use this thing.

Nitesh Kant wrote:
public class ClientSocketFactory implements RMIClientSocketFactory, Serializable { ... }


Must it happen before the UnicastRemoteObject gets constructed? or after?
just once? or as often as you like?
How does it relate to RMISocketFactory? Does it get bundled up and handed off to setSocketFactory somehow?
And does this solution pertain only to certain versions of Java?
Fors Judd
Greenhorn

Joined: Mar 26, 2012
Posts: 6
Also note that both these links are dead:
"RMI Naming.loookup timeouts"
"This link will also help."
 
jQuery in Action, 2nd edition
 
subject: RMI timeout