2

Using VisualVM, there are two types I can see to connect remote host.

  1. jstatd

  2. JMX

So I am trying to use JMX, I followed numerous tutorials but no luck so far.

Currently, there's my desktop and one linux box with java server application running. I am trying to setup VisualVM client on desktop to see java application running on the linux box.

I added following JAVA_OPTS script on start.sh script for the java application on linux.

JMX_PORT="-Dcom.sun.management.jmxremote.port=33333"  <-- allowed on firewall
JMX_SSL="-Dcom.sun.management.jmxremote.ssl=false"
JMX_AUTH="-Dcom.sun.management.jmxremote.authenticate=false"
JMX_IP="-Djava.rmi.server.hostname=xx.xx.xx.xx"   <-- where linux box NAT ip.

Java application on linux was successfully started with jmx options added start.sh, I assume since there's no error or warning.

When I tried to add JMX connection, it says it can't connect to it.

I checked if 33333 is blocked, it's not, I was able to connect to that ip with port using telnet from my desktop.

Is there any other port that I should open for VisualVM?

To use JMX, is there any other setup that I have to do such as RMI Registry server or jstatd policy file creation and start jstat daemon?? I thought it was for jstatd connection only so I didn't pursue that tutorial.

handicop
  • 892
  • 12
  • 25
  • 1
    I would just use a ssh tunnel, easiest and painless –  Dec 17 '13 at 06:57
  • 1
    @RC. Thanks for the comment, but port is not the main issue here as it's very closed network, I have to follow that specific procedures. The bottom line is that I do not have clear understanding of how JMX connection and VisualVM work. – handicop Dec 17 '13 at 07:12

2 Answers2

2

The easiest way is to use an openvpn tunnel between server and desktop than you get rid of the firewall an NAT things. I do it this way and it works like a charm.

LinuxLuigi
  • 693
  • 6
  • 14
1

I had no other clue how I can fix this so ended up using ssh tunnel.

  1. I added jmx run option into my java application start script on remote host. (jmxremote.port=33300, ssl to false, authenticate to false, hostname.)
  2. ssh -D 33300 on desktop to remote host.
  3. start jvisualvm using system_socks_proxy=localhost:33300 -J-Djava.net.useSystemProxies=true

Now remote host is successfully added using add new jmx connection on VisualVm.

ref. VisualVM over ssh

Community
  • 1
  • 1
handicop
  • 892
  • 12
  • 25
  • I don't like ssh tunnel because of the [TCP-over-TCP](http://sites.inka.de/bigred/devel/tcp-tcp.html) problems. With openvpn you are using UDP and you avoiding the TCP-over-TCP problems. – LinuxLuigi Dec 18 '13 at 09:26