Hi everybody:
I have a problem, I am working in a linux machine with jdk 1.6 that have two network interfaces one to comunicate with a private network 10.0.1.2 and another to communicate with another network outside 192.16.1.22.
I have made an RMI server that export an object that has one method that sums 2 numbers, then when I request the RMI server from the network 10.0.1.255 for example since 10.0.1.3 host everything works ok but when I access the RMI server from 192.16.1.20 I get this exception:
Exception in thread "main" java.rmi.ConnectException: Connection refused to host: 10.0.1.2; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at $Proxy0.getValue(Unknown Source)
at test.Client.main(Client.java:19)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.(Unknown Source)
at java.net.Socket.(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
... 8 more
This is my server Class:
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
public class Main {
public static void main(String[] args) {
try {
String rmiURL = "//localhost:2001/RMIServer";
String port = "2001";
System.out.println("Starting RMI server");
LocateRegistry.createRegistry(Integer.parseInt(port));
ObjectImpl impl = new ObjectImpl();
Naming.rebind(rmiURL, impl);
System.out.println("RMI Server started");
} catch (RemoteException e) {
System.err.println("There was an error initializing the registry");
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
and this is the client:
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
public class Client {
/**
* @param args
* @throws NotBoundException
* @throws RemoteException
* @throws MalformedURLException
*/
public static void main(String[] args) throws MalformedURLException, RemoteException, NotBoundException {
IObject test = (IObject) Naming.lookup("//192.16.1.22:2001/RMIServer");
System.out.println(test.getValue(30, 80));
}
}
The problem is that the RMI server only responds for one of the two networks interfaces of the machine and the objective is that it be able to responds for both interfaces.
Please could you help me to find out why is this happening ???
Regards
Ariel
Edited by: isaacrc82 on Feb 26, 2009 9:23 PM