java.rmi.ConnectException: Connection refused to host
After a hard work, I have set up Java RMI tunnelling using apache as http server. Everything is fine and Works like a charm at my office LAN.But when I installed at client's place, I am getting some exception.The RMI System works only on his server.
When I tried from other clients' pcs I get the following.
Can you guys help me solve this?
java.rmi.ConnectException: Connection refused to host: 172.xx.x.xxx;
nested exception is: java.net.ConnectException: Connection timed
out: 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 $Proxy1.getUserID(Unknown Source) at
rmi.source.ServerImpl$JobScheduler.run(ServerImpl.java:265) at
java.util.TimerThread.mainLoop(Unknown Source) at
java.util.TimerThread.run(Unknown Source) Caused by:
java.net.ConnectException: Connection timed out: 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.<init>(Unknown Source) at
java.net.Socket.<init>(Unknown Source) at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown
Source) at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown
Source) ... 10 more
I am running files from roseindia rmi
there is mistake rmicregistry, one have to use rmiregistry
:
I changed ip to localhost, how to run on special port number I don't know this moment one has to use rmiregistry not rmicregistry
so:
move to folder where does your class files take seat.
type : rmiregistry
then open 2 new command prompts move to same folder where classes seat and use one to run server and another to client.
RMI servers have the nasty habit to pass new port numbers to clients to handle the client communication to a particular Remote object. If this port number is blocked by the firewall, you would get an exception like that. Make sure you register all Remote objects with the same port number. RMI will then multiplex the client calls for you.
after my research, the solution is:
System.setProperty("java.rmi.server.hostname", IP)
;
before you register the service on server side. following is an example, hope it might help you!
public static void main(String[] args) throws MalformedURLException, RemoteException, AlreadyBoundException {
RmiServer server=new RmiServer();
System.setProperty("java.rmi.server.hostname", 指定IP);
LocateRegistry.createRegistry(8808);
Naming.rebind("//10.10.116.74:8808/SAMPLE-SERVER", server);
}
精彩评论