简体   繁体   English

java.rmi.ConnectException:连接被拒绝托管

[英]java.rmi.ConnectException: Connection refused to host

After a hard work, I have set up Java RMI tunnelling using apache as http server. 经过艰苦的工作,我使用apache作为http服务器来设置Java RMI隧道。 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. 一切都很好,并且在我的办公室LAN上像魅力一样运转。但是当我在客户端安装时,我遇到了一些例外。

When I tried from other clients' pcs I get the following. 当我尝试其他客户的PC时,我得到以下信息。

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 : 我正在从roseindia rmi运行文件rmicregistry出错,必须使用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 我将ip更改为localhost,如何在特殊端口号上运行我不知道这一刻必须使用rmiregistry而不是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. 键入: rmiregistry然后打开2个新命令提示符,将移动到类所在的文件夹,并使用一个运行服务器,将另一个运行到客户端。

RMI servers have the nasty habit to pass new port numbers to clients to handle the client communication to a particular Remote object. RMI服务器习惯将新端口号传递给客户端,以处理与特定Remote对象的客户端通信。 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. 然后,RMI将为您多路复用客户端呼叫。

after my research, the solution is: System.setProperty("java.rmi.server.hostname", IP) ; 经过我的研究,解决方案是: 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);  
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.rmi.ConnectException:连接被拒绝托管 - java.rmi.ConnectException: Connection refused to host java.rmi.ConnectException:连接被拒绝托管: - java.rmi.ConnectException: Connection refused to host: java.rmi.ConnectException:连接拒绝主机:本地主机; 在 Eclipse 中 - java.rmi.ConnectException: Connection refused to host: local host; in Eclipse java.rmi.ConnectException:连接被拒绝托管到主机192.168.56.1 - java.rmi.ConnectException: Connection refused to host 192.168.56.1 vs代码:java.rmi.ConnectException:连接拒绝主机:127.0.0.1 - vs code : java.rmi.ConnectException: Connection refused to host: 127.0.0.1 java.rmi.ConnectException:连接拒绝主机:192.168.0.55 - java.rmi.ConnectException: Connection refused to host: 192.168.0.55 java.rmi.ConnectException:连接拒绝主机:127.0.1.1; - java.rmi.ConnectException: Connection refused to host: 127.0.1.1; Java.rmi.ConnectException:连接被拒绝托管到主机:localhost - Java.rmi.ConnectException: Connection refused to host: localhost java.rmi.ConnectException:连接拒绝主机:192.168.1.8; 嵌套的异常是: - java.rmi.ConnectException: Connection refused to host: 192.168.1.8; nested exception is: java.rmi.ConnectException:拒绝连接主机:127.0.0.1 - java.rmi.ConnectException: Connection refused to host: 127.0.0.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM