jQuery in Action, 3rd edition
The moose likes Distributed Java and the fly likes connecting to RMI server through a router, problem. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "connecting to RMI server through a router, problem." Watch "connecting to RMI server through a router, problem." New topic

connecting to RMI server through a router, problem.

David Moran

Joined: Jan 20, 2005
Posts: 2
I have an RMI server running on a local machine within a wireless network.

I bind this server to the RMI registry with this call,

Naming.rebind("//localhost/Compute", engine);

This binds the server to the local area network (the wireless router) via
the local IP address the router provides for this particular machine, which is

Say, my WAN ip address (provided by the ISP) is I set-up a virtual server in the router so that any calls to the WAN ip address on port 1099, will be directed to port 1099 of the local machine, ip=

In my client I connect to the server with the following call,

compEngine = (Compute) Naming.lookup("rmi://");

It works great when the client is within the local network. However, when I try to connect outside of the local network, I have problems. It looks like the client finds the server and makes a connection. However, when I try to make a remote method call, I get the following exception:

java.rmi.ConnectException: Connection refused to host:; nested exception is:
java.net.ConnectException: Connection timed out: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
at sun.rmi.transport.tcp.TCPChannel.createConnection..............

I think there is a disconnect between the clients connection to the (WAN IP) and the (LAN IP)

I don't think it is my java.policy file, as I grant access to all, also, I have opened port 1099 in the firewall.

Has anybody experienced this? Thanks in advance, for your help.

[ January 20, 2005: Message edited by: David Moran ]
morten wilken

Joined: May 25, 2002
Posts: 13
we just went through a similar situation.

try to instruct both your client and server that you have a proxy in between.

use -Dhttp.propxtHost=IP_ADDR -Dhttp.proxyPort=PROXY_PORT on the server, and something similar on the client

hope it helps
I agree. Here's the link: http://aspose.com/file-tools
subject: connecting to RMI server through a router, problem.
jQuery in Action, 3rd edition