• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 420
  • Last Modified:

rmi and multiple IP addresses

Hi,

I have written an rmi server and client. The server is on a machine that has 2 IP addresses, a local one (192.168.0.1) and a public one (195.*.*.*). Now everything works properly if the client points to the local ip. However when I try to point the client to the public ip address (which is what I would like to do), it doesn't "see" the server. The only solution I have found for this is to disable the ethernet card which provides the local ip address.

The following is where I think I am missing something out, (in the server that is)


          String hostnameProperty = "java.rmi.server.hostname";      
          java.util.Properties systemProperties = System.getProperties();
          String hostname = systemProperties.getProperty(hostnameProperty);
          hostname = java.net.InetAddress.getLocalHost().getHostAddress();

          Registry reg = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
          reg.rebind(ReceiveMessageInterface.SERVER_NAME,s);


Thanks for your help
0
ahmed_alsamarrai
Asked:
ahmed_alsamarrai
  • 5
  • 3
1 Solution
 
CEHJCommented:
What is the value of 'hostnameProperty' btw?
0
 
ahmed_alsamarraiAuthor Commented:
Hi,

          String hostnameProperty = "java.rmi.server.hostname";  

is that what you wanted to know?

thanks
0
 
CEHJCommented:
Sorry, LOL

'hostname' not 'hostnameProperty'
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
ahmed_alsamarraiAuthor Commented:
I'm not sure I understand! if I print out the value of hostname, I get the local ip address: 192.168.0.1

To be honest, I'm not sure exactly what is the purpose of each line. What I require is that the server "binds" on the public ip address and not the local one.

thanks
0
 
CEHJCommented:
>>To be honest, I'm not sure exactly what is the purpose of each line

Nor am i ;-) Certainly the fourth line overwrites the third.

Try doing

hostname

at the command line, then

InetAddress public = InetAddress.getByName(<put the hostname in here>);
0
 
ahmed_alsamarraiAuthor Commented:
ok...

I think that the only things which have an effect on the rmi Server are the last 2 lines of my code:
          Registry reg = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
          reg.rebind(ReceiveMessageInterface.SERVER_NAME,s);

as I commented the rest out and it did not have any effect....

it still always uses the local ip address

by the way, s, which appears in the second line is the rmi Server object

i just don't know where to specify the public ip address...

thanks
0
 
ahmed_alsamarraiAuthor Commented:
Hi,

what am i supposed to do with the public string afterwards... how do I tell the rmi server to use that? basically, how do I tell it to use the public ip address?

thanks
0
 
ahmed_alsamarraiAuthor Commented:
ok i just figured it out..... at the command prompt, when I run the program i do:

java -Djava.rmi.server.hostname=195.x.x.x RmiServer

thanks anyway
0
 
moduloCommented:
PAQed, with points refunded (50)

modulo
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now