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
posted
0
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 :
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.
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: 3
posted
0
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?