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

时间:2015-11-10 00:57:37

标签: java server client client-server rmi

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

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 ---");


    }

1 个答案:

答案 0 :(得分:1)

  

不,我没有启动注册表。

停在那儿。在启动注册表之前,你不会得到。你无法连接到那里没有的东西。

奇怪的是你得到了一个连接超时而不是“拒绝连接”,但这里没有其他任何东西需要解释。

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