0

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


    }
James Webster
  • 31,873
  • 11
  • 70
  • 114
Na Dia
  • 195
  • 1
  • 4
  • 11
  • 1
    Please [edit] your question to include links to those other posts you tried. Thanks for improving the question's reference value and making it more answerable! – Nathan Tuggy Nov 10 '15 at 01:25
  • 1
    Have you started the Registry? Is 10.0.0.57 your local IP address? This looks like a DNS misconfiguration at first glance. – user207421 Nov 10 '15 at 09:17
  • yes local IP/10.0.0.57. No I have not started the registry, I followed suggestions in the link below, where: System.setProperty("java.rmi.server.hostname","192.168.1.2"); fixed similar issue: http://stackoverflow.com/questions/15685686/java-rmi-connectexception-connection-refused-to-host-127-0-1-1 also read throughhttp://docs.oracle.com/javase/7/docs/technotes/guides/rmi/faq.html#domain I do not really understand why setting property java.mi.server.hostname does not help, maybe I am not doing it right. Im not really an expert in TCP and IP connections. – Na Dia Nov 10 '15 at 10:34
  • I have read in the post : "The appropriate workaround is to set the system property java.rmi.server.hostname when starting the server. The value of the property should be the externally reachable hostname (or IP address) of the server -- whatever works when specified as the host-part in Naming.lookup is good enough." From my code you can see that I set the system property to "191.234.6.152", however it still seems to be set to localIP. Should I set it to non local address?and what address should it be? http://docs.oracle.com/javase/7/docs/technotes/guides/rmi/faq.html#domain – Na Dia Nov 10 '15 at 11:25
  • there is also link answer to similar problem by Robert Munteanu [link] http://stackoverflow.com/users/112671/robert-munteanu. I have not tried it yet. Since I am not 100% sure how to add this entry to the host file. Maybe you can help with his suggestion by clarifying how to do that: [link] http://stackoverflow.com/questions/1167551/how-do-i-have-to-configure-a-rmi-environment-so-that-im-able-to-use-it-in-a-re – Na Dia Nov 10 '15 at 11:38
  • My host file looks like: What changes should I make for rmi connection to work? # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost – Na Dia Nov 10 '15 at 11:47

1 Answers1

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.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • Ok I have started the Registry or created it should I say: Output: --- Registry running! --- It seems fine, until I run Class with code specified above, where I get the same error as previously. I could add code for both classes, if stack overflow would allow me to do that. LocateRegistry.createRegistry(5099, new SslRMIClientSocketFactory(), new SslRMIServerSocketFactory(null, null, true)); System.out.println("--- Registry running! ---"); – Na Dia Nov 10 '15 at 20:56
  • Thanks for comments and tips btw! – Na Dia Nov 10 '15 at 21:01