1

Consider this setup: JMX Server with multiple clients

So there's a JMX Server and we want it to be reachable from different JMX Clients, but the problem is that these different JMX clients knows HostX by different names/addresses. For the sake of the example lets say that HostA knows HostX by the name of hostx but HostB knows HostX by the name of hostxshadow.

I'm looking for recommendations on how to solve this problem under the following scenarios:

  1. Where I have control over the source code of the JMX Clients and JMX Server.

  2. Where I have no control over the source code, i.e. I can set System Properties on the JVM, but that's it.

The basic problem to be solved is that in the RMI world the server-side decides how a client should connect (right?). So setting e.g. java.rmi.server.hostname on HostX isn't going to help. As I see it I can only make either HostA happy or HostB happy, but not both at the same time.

Is the conclusion really that any RMI Server can only work if all clients would use the same name to access it?

2
  • Can you solve this by making the same name resolve to different IPs? So HostA when it looks up hostx gets the internal IP while HostB gets the shadow IP?
    – Gray
    Feb 5, 2014 at 15:12
  • I don't have control over the environment into which the JMX solution gets deployed.
    – peterh
    Feb 5, 2014 at 16:25

3 Answers 3

1

Your conclusion is correct. It's a design flaw in RMI. There is an underlying assumption that there is a single 'most public' hostname or IP address by which the server host can be contacted by everybody.

Your statement about the host embedding its own name or address in the stub is also correct.

3
  • Thanks for the verification. Having my assumptions verified has great value to me even though I was secretly hoping I was wrong. :-) I'll accept this answer.
    – peterh
    Feb 6, 2014 at 7:21
  • 1
    If you can find the java-RMI mailing list archive, it was discussed there ten or more years ago. There is a solution, but firstly it requires a change to RMI (which I suggested at the time), and secondly it requires Sun/Oracle to accept the existence of the problem, and you will see by the exchange that that was never going to happen.
    – user207421
    Feb 6, 2014 at 7:35
  • LoL. In terms of a workaround that doesn't require changes to RMI itself I've just found this. I think it is quite clever. Only works in scenario 1 above and has lots of caveats .. but clever thinking.
    – peterh
    Feb 6, 2014 at 10:05
0

RMI is one possible transport of JMX. Another solution is JMXMP and switching to it is very simple, check at http://meteatamel.wordpress.com/2012/02/13/jmx-rmi-vs-jmxmp/ or http://blog.markfeeney.com/2010/10/jmx-through-ssh-tunnel.html.

1
  • Hmm. Yes. I just cannot figure out what the official state of that connector is vs the rmi connector? Do they work equally well, fast, stable? What if I have a problem? There seems to be great knowledge (still) out there wrt to rmi but what about jmxmp?. But true, from googling it does seem people are having a positive experience with jmxmp.
    – peterh
    Feb 6, 2014 at 7:46
0

The basic problem to be solved is that in the RMI world the server-side decides how a client should connect (right?). So setting e.g. java.rmi.server.hostname on HostX isn't going to help. As I see it I can only make either HostA happy or HostB happy, but not both at the same time.

This is not going to help you but for others, the trick to do is to set the java.rmi.server.hostname system property to a name that means something on HostA which is inside of the firewall but another thing to HostB which is outside.

For example, in EC2 land we set the hostname property to be the EC2 node's "public hostname" which we get by doing a:

wget -q -O - http://169.254.169.254/latest/meta-data/public-hostname

This resolves to be some like:

ec2-54-1-2-3.compute-1.amazonaws.com

On the box itself and any others that are inside of EC2 this resolves to be 10.1.2.3 while on the outside world it resolves to the externally facing IP 54.1.2.3. Amazon does this DNS work by default. You may need to adjust the /etc/hosts file as necessary to get the names to be correct.

For more details on EC2 and JMX, see: How to connect to Java instances running on EC2 using JMX

1
  • Gray, I already mentioned java.rmi.server.hostname in my original posting and why it isn't going to help. But thanks.
    – peterh
    Feb 6, 2014 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.