RMI only works over network and not over internet

Discussion in 'Java' started by zach.bastick@gmail.com, Feb 19, 2005.

  1. Guest

    Hello

    I am testing an RMI application that I have written and have found that
    my client can only connect to servers which are in my local network
    (192.168.* and 10.0.*). I have tried to connect to servers over the
    internet with no success. I can, however, ping the remote machines, and
    I am sure that they have no restrictive firewalls on them.

    If anyone could help me solve this problem I would be very grateful


    Zach
     
    , Feb 19, 2005
    #1
    1. Advertising

  2. What is the exception type?
    How do the servers publish their remote objects? How are the objects bound
    to the IP address?
    Do the servers have multiple network interfaces (multi-homing hosts)?
    How do you connect to the servers (example of the Naming.lookup()
    parameters)?
    Is your client behind a firewall?

    Without knowing all these, not much can be offered in the way of help.

    Alex Molochnikov
    Gestalt Corporation

    <> wrote in message
    news:...
    > Hello
    >
    > I am testing an RMI application that I have written and have found that
    > my client can only connect to servers which are in my local network
    > (192.168.* and 10.0.*). I have tried to connect to servers over the
    > internet with no success. I can, however, ping the remote machines, and
    > I am sure that they have no restrictive firewalls on them.
    >
    > If anyone could help me solve this problem I would be very grateful
    >
    >
    > Zach
    >
     
    Alex Molochnikov, Feb 19, 2005
    #2
    1. Advertising

  3. Guest

    Thanks for the reply.

    Here is the code that the server uses:

    java.rmi.registry.LocateRegistry.createRegistry(defport);
    Services server = new ServicesImpl();
    Naming.rebind("rmi://localhost:48594/ControlService", server);


    Here is the code that the client uses:

    if(System.getSecurityManager() == null)
    System.setSecurityManager(new RMISecurityManager());
    s = (Services)Naming.lookup("rmi://"+host+":48594/ControlService");


    The exception that I get when trying to connect to a machine over the
    internet is:
    Can't Connect: Connection Refused to HostConnection refused to host:
    [THE REMOTE IP IS HERE]; nested exception is:
    java.net.ConnectException: Connection timed out: connect

    However the remote machine has no firewall and I can ping it. I have
    tried this on 3 computers over the internet, and I get the same
    response from all of them.
     
    , Feb 20, 2005
    #3
  4. You did not answer the question of multi-homing remote hosts. I assume the
    server has only one NIC. In this case, try binding the NIC address like
    this:

    Naming.rebind("rmi://[SERVER'S PUBLIC IP ADDRESS]:48594/ControlService",
    server);

    (do not use "localhost" - it is not a valid domain name on the Net).

    If the server does have multiple NICs, you will need to set the following
    property _prior_ to binding:

    String publicAddress = [PUBLIC IP ADDRESS OF THE SELECTED NIC];
    System.getProperties().put("java.rmi.server.hostname", publicAddress);


    <> wrote in message
    news:...
    > Thanks for the reply.
    >
    > Here is the code that the server uses:
    >
    > java.rmi.registry.LocateRegistry.createRegistry(defport);
    > Services server = new ServicesImpl();
    > Naming.rebind("rmi://localhost:48594/ControlService", server);
    >
    >
    > Here is the code that the client uses:
    >
    > if(System.getSecurityManager() == null)
    > System.setSecurityManager(new RMISecurityManager());
    > s = (Services)Naming.lookup("rmi://"+host+":48594/ControlService");
    >
    >
    > The exception that I get when trying to connect to a machine over the
    > internet is:
    > Can't Connect: Connection Refused to HostConnection refused to host:
    > [THE REMOTE IP IS HERE]; nested exception is:
    > java.net.ConnectException: Connection timed out: connect
    >
    > However the remote machine has no firewall and I can ping it. I have
    > tried this on 3 computers over the internet, and I get the same
    > response from all of them.
    >
     
    Alex Molochnikov, Feb 21, 2005
    #4
  5. Guest

    ok
    i did what you said and tried to bind my public IP after setting the
    property.
    However, it just won't bind. I get this error:

    nested exception is:
    java.net.ConnectException: Connection refused: connect

    It seems to me that, since I am behind a NAT, this is my internet
    gateways IP. Hence, I am trying to bind the server to the IP of another
    machine..

    Is there no way around this besides running the program on the gateway
    machine (which I can't do since that machine belongs to my ISP)?
     
    , Feb 22, 2005
    #5
  6. I can only help you if you help me understand your environment. This is what
    you said in your original post:

    > I am sure that they [servers - A.M.] have no restrictive firewalls on them


    Now you say:

    > since I am behind a NAT


    NAT _is_ a firewall - or, at least, that aspect of the firewall that
    requires careful consideration when setting up the RMI connections.

    So, let me ask you again:

    What is the configuration of the network between your client and server
    machines? E.g. the client is behind a firewall, or the server is behind a
    firewall, or both. If the server is behind the firewall, then is the IP
    address of the firewall on the ISP side static or dynamic?

    If your server is indeed behind the firewall, and the configuration is
    something like:

    internet > external NIC > firewall > internal NIC > LAN > server host
    (here "external NIC" and "internal NIC" are network cards inside the
    firewall, at the public and private ends)

    then you have to bind the server object to your _local_ (private) IP address
    of the server host, but the java.rmi.server.hostname property must be set to
    the external IP address of the firewall. Your client, when locating the
    server, will also have to use that same external IP address in order to
    connect to the server. Finally, the firewall (or NAT router - whatever it is
    called at your location) will have to route packets destined to the server
    (based on say port number) from the external to the internal NIC.

    Alex Molochnikov
    Gestalt Corporation
     
    Alex Molochnikov, Feb 22, 2005
    #6
  7. Guest

    it sounds like it would be difficult to create a protable RMI
    application, given the specific settings that have to be programmed for
    each network set up.
     
    , Feb 23, 2005
    #7
  8. You do not program "specific settings" in your RMI-based (i.e.
    client-server) application. Instead, the parameters that are likely to vary
    from one installation to another must be put into an external file (like
    property file) to be edited by whoever does the installation, and your
    server and client get these parameters (server IP address, port etc.) from
    this file. Of course, nothing stops you from providing a nice-looking GUI to
    make the property editing easier for the users.

    And if firewalls are involved, then some cooperation from the firewall admin
    will be required - but this hardly makes the RMI applications non-portable.
    For examples of live RMI-based products that are "portable" you can visit
    our websites: www.reportgenerator.org or www.gestalt.com.

    Alex Molochnikov
    Gestalt Corporation

    <> wrote in message
    news:...
    > it sounds like it would be difficult to create a protable RMI
    > application, given the specific settings that have to be programmed for
    > each network set up.
    >
     
    Alex Molochnikov, Feb 23, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jane Davis

    Network Service account over network

    Jane Davis, Jun 22, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    478
    Kevin Spencer
    Jun 22, 2005
  2. Buu Nguyen

    RMI, JINI or RMI/IIOP

    Buu Nguyen, Aug 25, 2004, in forum: Java
    Replies:
    1
    Views:
    601
    Sudsy
    Aug 25, 2004
  3. JScoobyCed

    RMI Vs RMI over IIOP

    JScoobyCed, Jan 28, 2005, in forum: Java
    Replies:
    1
    Views:
    778
    Dag Sunde
    Jan 28, 2005
  4. Jan Schulze
    Replies:
    1
    Views:
    598
    Esmond Pitt
    Mar 26, 2005
  5. dushkin
    Replies:
    0
    Views:
    379
    dushkin
    Apr 23, 2006
Loading...

Share This Page