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

I am quite a beginner with NetBeans and Java, so I'm pretty sure my questions are very basic but trying to find the solution for 2 weeks I am totally stuck

This is the problem:

I want to implement a RMI Server Client application So first step was trying with NetBeans to have one work from the net

I used the oracle tutorial to have the first part implemented http://docs.oracle.com/javase/tutorial/rmi/server.html

My problem is not that the client does not connect, but that the server can't even register in the port I give him. The IP in the error message is my private IP.

This is the error message I get:

Conectando a:  127.0.0.1 / 19400 / PlanificadorTalsa
ServidorPlanificadorStarter exception:
java.rmi.ConnectException: Connection refused to host: 192.168.0.55; nested exception is: 
    java.net.ConnectException: Connection refused: connect
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
    at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:342)
    at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
    at   Starter.ServidorPlanificadorStarter.main(ServidorPlanificadorStarter.java:52)
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at java.net.Socket.<init>(Socket.java:434)
    at java.net.Socket.<init>(Socket.java:211)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
    ... 5 more

I am running windows 8.1, and disabled firewall. I am also using a security file granting all permissions

this is my java code I execute from NetBeans:

import Conexion.DatosConexion;
import Servidor.*;

import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

public class ServidorPlanificadorStarter implements InterfazServidorPlanificador {

   private static String ip;
   private static String Servidor = "SERVIDORNUBE";
   private static int puerto;
   private static String nombreServidor;

   public ServidorPlanificadorStarter(){
       super();
   }

   public static void main(String[] args) {
       if (System.getSecurityManager() == null) {
           System.setSecurityManager(new SecurityManager());
       }
       try {
           DatosConexion datos = DatosConexion.getInstance();

           ip = datos.getServiceIP(Servidor);
           puerto = Integer.valueOf(datos.getServicePort(Servidor));
           nombreServidor = datos.getServiceName(Servidor);

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

           System.out.println("Conectando a:  " + ip + " / " + puerto + " / " + nombreServidor);

           InterfazServidorPlanificador engine = new ServidorPlanificadorStarter();
            InterfazServidorPlanificador stub =
                (InterfazServidorPlanificador) UnicastRemoteObject.exportObject(engine, puerto);
            Registry registry = LocateRegistry.getRegistry();
            registry.rebind(nombreServidor, stub);
            System.out.println("ServidorPlanificador bound");
        } catch (Exception e) {
            System.err.println("ServidorPlanificadorStarter exception:");
            e.printStackTrace();
        }
    }

}

The interface is as follows (very basic, as I have done nothing with it)

public interface InterfazServidorPlanificador extends Remote {

    //void addObserver(RemoteObserver o) throws RemoteException;

}

Upvotes: 0

Views: 8581

Answers (1)

maxormo
maxormo

Reputation: 629

Did you start RMI registry as in tutorial? http://docs.oracle.com/javase/tutorial/rmi/running.html

Upvotes: 2

Related Questions