java.rmi.ConnectException:连接被拒绝主机:10.0.0.57

java.rmi.ConnectException: Connection refused to host: 10.0.0.57

为什么我不断收到以下错误?我试图通过关注类似问题的帖子来解决问题,但似乎没有任何效果。

java.rmi.ConnectException: Connection refused to host: 10.0.0.57; nested exception is: 
java.net.ConnectException: Operation timed out
at .....
javax.rmi.ssl.SslRMIClientSocketFactory.createSocket(SslRMIClientSocketFactory.java:120)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 5 more

public static void main(String[] args) throws UnknownHostException {
        // Bind to registry
        System.setProperty(
                "javax.net.ssl.keyStore",
                "/Users/xxxx/keys/printserver.jks");
        System.setProperty("javax.net.ssl.keyStorePassword", "password");
        System.setProperty(
                "javax.net.ssl.trustStore",
                "//Users/xxxx/keys/printserver.jks");
        System.setProperty("javax.net.ssl.trustStorePassword", "password");
        System.setProperty("javax.net.ssl.debug", "all");

        //System.out.println(java.net.InetAddress.getLocalHost());

        try {
            System.setProperty("java.rmi.server.hostname", "191.234.6.152");
            Registry r = LocateRegistry.getRegistry(null, 5099, new SslRMIClientSocketFactory());
            r.bind("LoginServer", new LoginServer());
            System.out.println("--- Login Server ready ---");


    }

No I have not started the Registry.

到此为止。在启动注册表之前, 您什么也做不了。你无法连接到不存在的东西。

奇怪的是你得到的是连接超时而不是 'connection refused',但这里没有其他需要解释的了。

设置java.rmi.server.hostname不会解决这个问题。您在此处引用的问题中有 None 个是类似问题。都是客户端执行远程方法时拒绝连接。这是绑定到注册表时 服务器 中的连接拒绝。