• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RMI binding to more than one IP

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi , in my application where the clients communicate with the server through RMI, the exported remote objects are bound to the hostname set in "java.rmi.server.hostname" system property.

If the server has two NIC cards, then is it possible for the clients on different networks to connect to the server with the Network IP address to which it belongs other than the default one (obtained from system property) (ie) is it possible for the RMI server to listen for requests coming on both the IP adresses. Will the Custom RMI Socket factory helps in this.
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Won't binding the server at 0.0.0.0 and removing java.rmi.server.hostname system property do it for you?
This would mean that the server listens to all interfaces and the client can use any interface.

Or is it so that you want to restrict the clients only to a certain set of Interfaces?
 
Raman Naresh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for the response. Please let me know how to bind it to 0.0.0.0 as CreateRegistry and bind methods do not have arguments to take ipaddress.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you do not specify any host using RMIServerSocketFactory, it will bind to 0.0.0.0.

(Sorry, i should have commented on this before)

Raman: the exported remote objects are bound to the hostname set in "java.rmi.server.hostname" system property



Nope, actually, this property is for the hostname the clients will connect on.
So, the server is exported on the hostname(interface) that is specified by the server socket factory and clients connect to interface specified by "java.rmi.server.hostname" system property, if any.
This bug has more details.

So, in your code, i guess you just need to remove "java.rmi.server.hostname" system property and things should fall in place.
[ December 01, 2008: Message edited by: Nitesh Kant ]
 
Raman Naresh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, can you please know me the diference between RMIServerSocketFactory and RMIClientSocketFactory. As far as my understand when we use RMIClientSocketFactory while exporting the object , RMI creates the socket from client to server by takeing the ipaddress that is supplied as an argument to RMIClientSocketFactory Impl constructor instead of using InetAddress.getLocalHost.getAddress().

In this way , I can get rid of the localhost server address and use the ipaddress which the client can communicate. This works for the one client, but with multiple clients , im not able to export the same object with differnt ipaddress as it says objectID already in use. IN our network we have two clients , one from 10.10.10.x and other from 20.20.20.x . The server has one internal ipaddress 192.168.2.2 and two additional NIC cards , one is 10.10.10.1 and the other 20.20.20.1, in this way the two client cannot communicate with each other and RMI should be enabled on all the three ipaddress, ie client from 10.10.10.x should communicate with server thru 10.10.10.1 and client from 20.20.20.x should communicate with server thru 20.20.20.1

I also tried with creating the registry with RMIServerSocketFactory with no argument. But its not working. Could you please provide me an example.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Raman: IN our network we have two clients , one from 10.10.10.x and other from 20.20.20.x . The server has one internal ipaddress 192.168.2.2 and two additional NIC cards , one is 10.10.10.1 and the other 20.20.20.1, in this way the two client cannot communicate with each other and RMI should be enabled on all the three ipaddress, ie client from 10.10.10.x should communicate with server thru 10.10.10.1 and client from 20.20.20.x should communicate with server thru 20.20.20.1



Can't you have a single interface for the RMI stub? Why is it required that the client from 10.10.10.x should have a different IP address in the RMI stub too.
I think there are two things:
  • Interface at which the rmi registry is running.
  • Interface at which the client stub is connecting.


  • If by saying "rmi is enabled" means the registry is available then you would have to have a routing rule i guess that will route all traffic from one interface on the registry port to another or a common interface to which the data is routed to from both 10.10.10.x and 20.20.20.x.
    (I must say that I am not a networking expert but this is what i can think of)

    If you are saying the client stub must contain different interfaces according to the interface on which it is invoked, then this is difficult if not impossible.
    What is it that you loose if your client stub always connects on one IP address and registry is available on both?
    I am sure nobody cares what interface the client stub is connecting too as long as the interface is a publicly available IP.
    [ December 04, 2008: Message edited by: Nitesh Kant ]
     
    reply
      Bookmark Topic Watch Topic
    • New Topic