This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Distributed Java and the fly likes Dynamically set RMI Timeout from client 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 » Java » Distributed Java
Bookmark "Dynamically set RMI Timeout from client " Watch "Dynamically set RMI Timeout from client " New topic
Author

Dynamically set RMI Timeout from client

Saurabh. Arora
Greenhorn

Joined: Apr 27, 2011
Posts: 4

Hi,

I am stuck with following RMI timeout problem and need urgent help,

1) Is there any way for configuring dynamically different RMI timeout values at RMI client depending upon some criteria.
2) Is there any way to override "sun.rmi.transport.tcp.responseTimeout" value at RMI client depending upon some criteria.


I tried below ways, but none of them worked. Is there any genius who can let me out of this problem.

1) I tried setting "sun.rmi.transport.tcp.responseTimeout" dynamically, but it only accept values that is set very first time.
System.getProperties().setProperty("sun.rmi.transport.tcp.responseTimeout",
rmiTimeout);

2) To override system properties dynamically, I tried way as below but that did not work
FileInputStream propFile = new FileInputStream("myProperties.txt");
Properties p = new Properties(System.getProperties());p.load(propFile);
p.setProperty("sun.rmi.transport.tcp.responseTimeout",rmiTimeout); System.setProperties(p);

3) I created rmiclientSocketFactory and pass it to LocateRegistry.getRegistry … but that did not work.
GUIClientSocketFactory guiClientSocketFactory = new GUIClientSocketFactory(Integer.parseInt(rmiTimeout));
public Socket createSocket(String host, int port) throws IOException {
Socket socket = new Socket(host, port);
socket.setSoTimeout(timeout);
return socket;
}
Registry reg = LocateRegistry. getRegistry(props.getProperty("rmiIpAddress"), (new Integer(props.getProperty("rmiPort"))) .intValue(),guiClientSocketFactory);

Any help will be extremely appreciated.

Thanks.
roshan sinha
Greenhorn

Joined: Aug 28, 2013
Posts: 9

RMISocketFactory.setSocketFactory(new RMISocketFactory()
{
public Socket createSocket(String host, int port) throws IOException {
Socket socket = new Socket(host, port);
socket.setSoTimeout(timeoutMillis);
socket.setSoLinger(false, 0);
return socket;
}
public ServerSocket createServerSocket(int port) throws IOException {
return new ServerSocket(port);
}
});


you can try this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamically set RMI Timeout from client
 
Similar Threads
Server Program - Responding To Post Requests From HTML pg.
I want to use java properties from an interface
How to put some code in one spot, rather than needing it in multiple classes and methods
Socket timeouts for RMI
org.apache.cxf.interceptor.Fault: Marshalling Error: null