Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

rmi and multiple IP addresses

Posted on 2003-10-29
10
Medium Priority
?
398 Views
Last Modified: 2012-05-05
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
Comment
Question by:ahmed_alsamarrai
  • 5
  • 3
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 9643087
What is the value of 'hostnameProperty' btw?
0
 

Author Comment

by:ahmed_alsamarrai
ID: 9643356
Hi,

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

is that what you wanted to know?

thanks
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9643505
Sorry, LOL

'hostname' not 'hostnameProperty'
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ahmed_alsamarrai
ID: 9647072
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 9651951
>>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
 

Author Comment

by:ahmed_alsamarrai
ID: 9669015
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
 

Author Comment

by:ahmed_alsamarrai
ID: 9855179
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
 

Author Comment

by:ahmed_alsamarrai
ID: 9855228
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
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11464545
PAQed, with points refunded (50)

modulo
Community Support Moderator
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month20 days, 19 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question