java.rmi.ConnectException: Connection refused to host: 127.0.1.1;

前端 未结 14 2621
攒了一身酷
攒了一身酷 2020-11-27 15:08
    java.rmi.ConnectException: Connection refused to host: 127.0.1.1; nested exception is:
    java.net.ConnectException: Connection refused
    at sun.rmi.transport         


        
14条回答
  •  [愿得一人]
    2020-11-27 15:41

    PROBLEM SOLVED

    I had exactly the same error. When the remote object got binded to the rmiregistry it was attached with the loopback IP Address which will obviously fail if you try to invoke a method from a remote address. In order to fix this we need to set the java.rmi.server.hostname property to the IP address where other devices can reach your rmiregistry over the network. It doesn't work when you try to set the parameter through the JVM. It worked for me just by adding the following line to my code just before binding the object to the rmiregistry:

    System.setProperty("java.rmi.server.hostname","192.168.1.2");

    In this case the IP address on the local network of the PC binding the remote object on the RMI Registry is 192.168.1.2.

提交回复
热议问题