I've got a jmx server behind a NAT, setting java.rmi.server.hostname to the public IP allowed me to connect remotely, however now I can't connect locally (same LAN of the server behind NAT) any more.
The problem is that even if the local jmx client tries to connect to service:jmx:rmi://<internal IP>:jmxPort/jndi/rmi://<internal IP>:rmiPort/jmxrmi
then after establishing the connection to the RMI registry it'll receive the RMI stubs with the public IP of the server (not the internal IP) and the connection will fail as it would require NAT reflection to work.
Is there an easy solution for this?
Would it be possible at the jmx client side to rewrite the IP in the RMI stubs?
Thanks for any help
There is a basic assumption in Java RMI/JRMP that there is a single public IP address of the server that can be addressed from anywhere, and that is what java.rmi.server.hostname should be set to. If that assumption is false the whole thing breaks.