posted 23 years ago
Hi,
I wrote an client/server app that uses RMI to exec/stop threads.
The client part creates rmiregistry on the port that I pick up from config file, same for my RMI object:
public AgentsManager() throws RemoteException{
try{
conf = ClientProperties.getInstance();
AgentFactory.init();
}catch(IOException ioe){
ExceptionHandler.handle(ioe,this.getClass());
System.exit(1);
}
port = Integer.parseInt(
conf.getProperty("port", "-1"));
if(port <= 1024 | | port >=65535){
port = 6566;
cat.warn("Port number error. 0 < port < 65535 The port was reset to 1100");
}
rmiPort = Integer.parseInt(
conf.getProperty("rmiPort", "-1"));
if(rmiPort <= 1024 | | rmiPort >=65535){
rmiPort = 6565;
cat.warn(
"RMI Port number error. 0 < port < 65535 The port was reset to 1099");
}
UnicastRemoteObject.exportObject(this, port);
}
private void connect() throws RemoteException{
try{
rmiregistry = LocateRegistry.createRegistry(rmiPort);
}catch(RemoteException re){
rmiregistry = LocateRegistry.getRegistry(rmiPort);
}
try{
rmiregistry.rebind(NAME, this);
}catch(Exception ce){
ce.printStackTrace();
}
}
Everything worked fine until firewall was installed. Firewall configured to allow 2 way comm on my ports. However, in order to do a lookup server picks a random port. Therefore, firewall blocks reply to that port and server times out. Is there any way to force server to use fixed port for lookup and communication??
Thank tou, Yarik.