Connecting to an RMI object without registry

Posted by Mark Probst on Stack Overflow See other posts from Stack Overflow or by Mark Probst
Published on 2010-06-09T09:40:28Z Indexed on 2010/06/09 9:42 UTC
Read the original article Hit count: 243

Filed under:
|
|
|
|

I think I need to connect to a remote RMI object without going through the registry, but I don't know how.

My situation is this: I'm implementing a simple job distribution service which consists of one distributor and multiple workers. The distributor has a registered RMI object to which clients connect to send jobs, and workers connect to accept jobs.

Unfortunately the distributor and worker hosts are behind a firewall. To get to the distributor host I am tunneling two ports (one for the registry, one for the distributor object) via SSH, so I can get to the registry and the distributor from outside the firewall. To make that work I have to set "-Djava.rmi.server.hostname=localhost" on the distributor JVM so that the clients connect to their local, tunneled port, instead of the port on the actual distributor host, which is blocked.

This creates a problem for the workers, though, because they need to connect to the distributor directly, but because of the "localhost" redirection they behave like clients and try to connect to a port on their own host, which is not available, because I'm not tunneling on the workers (it is impractical).

Now, if I could connect to a remote object directly by giving the hostname and port, I could do away both with the registry on the distributor and the "localhost" hack, and make the workers connect properly.

How do I do that? Or is there a different solution to this problem?

© Stack Overflow or respective owner

Related posts about java

Related posts about ssh