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 ?
Alex Belisle Turcot
Joined: Apr 26, 2005
I'm at work and can't try it.. but you got me thinking and wanted to know for myself, and I found this :
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:
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.
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?