java.rmi.ConnectException: Connection refused to host: 10.0.0.57 [duplicate]

隐身守侯 提交于 2019-12-12 01:25:42

问题


Why I continue to receive following error? I tried to fix a problem by following posts on similar issue, however nothing seems to work.

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:


No I have not started the Registry.

Stop right there. You're not going to get anywhere until you start the Registry. You can't connect to something that isn't there.

It's strange that you're getting a connection timeout rather than 'connection refused', but there is nothing else here that needs explaining.

Setting java.rmi.server.hostname won't fix this problem. None of the questions you have cited here is a similar issue. They are all connection refusals in the client when executing a remote method. This is a connection refusal in the server when binding to the Registry.



来源:https://stackoverflow.com/questions/33621097/java-rmi-connectexception-connection-refused-to-host-10-0-0-57

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!