Hi,
I'm working on a server which interfaces with various types of clients:
- "Full featured clients" may only be able to see a load balancer / firewall VIP; the server IP may be NAT'd from them.
- "Admin clients" typically connect directly to the server.
It's very surprising that RMI / NAT is not handled better by Java. Have seen various postings with references to 'java.rmi.server.hostname'. However, it applies to the entire server process so won't work here.
Instead, I noticed that a single call to Registry.lookup() serializes multiple instances of RMIClientSocketFactory to the client (i.e. with different stack traces):
1) In the first instance, the host parameter of RMIClientSocketFactory.createSocket() is the VIP.
2) In future instances, it is the server's IP.
The solution that appeared to work for me is to use the host from that first instance in all future calls to RMIClientSocketFactory.createSocket().
Has anyone encountered this situation? Did you find any better alternatives?
Thanks in advance.