File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Distributed Java and the fly likes RMI Server and Client behind two different routers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI Server and Client behind two different routers" Watch "RMI Server and Client behind two different routers" New topic

RMI Server and Client behind two different routers

bertrand moulard

Joined: Feb 08, 2005
Posts: 6

I wrote a RMI server and a RMI client. The client calls some methods on the server and the server keeps a reference of the client to send some events.

Everything works great on the local network.

I tried to run it over the internet and in order to do so, set the property java.rmi.server.hostname=[public-ip-of-the-server-router]. I now have two different problems.

1 - For the server to be able to call back the client, I had to set the java.rmi.server.hostname=[public-ip-of-the-client-router] and forward the port 1099 to the client machine on the client router. I would like to be able to avoid that so that anyone could run the client without having to worry about router port forwarding. Ideally the customers could run the client anywhere and we can't excpect them to know how to configure a router.

2 - If I set java.rmi.server.hostname to the public ip on the server, it is no more available to the eventual clients that could run on the same local network as the server. That is because the public ip is not qualified from within the network. Is there a way to have the server available both on the public ip and the LAN ip?

Many thanks in advance.

Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

1 is going to be very difficult - the answer to "So what do I have to do to get RMI to operate through two firewalls?" in Sun's RMI FAQ really discourages use of client-side callbacks for exactly this reason. There *are* things you can do, but unfortunately, most (if not all) will require either some up-front client-side configuration.

2 confuses me - why can't clients on the network access the public IP of the server? Wouldn't this just require changing router configuration to allow them to?

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
bertrand moulard

Joined: Feb 08, 2005
Posts: 6
Thanks for your answer.

For the first point, I thought it might be the case and I removed the callbacks and replaced the RMI event propagation by a socket client-server system.

For the second point, it's because the routers of the networks where we want to install our system don't support that feature. They are cheap and nasty, and are installed in so many locations that we can't even start thinking about replacing them.

Thanks again

I agree. Here's the link:
subject: RMI Server and Client behind two different routers
It's not a secret anymore!