Failed to connect to remote JMX with jconsole

I am developing offline Spring3.1.

I am trying to connect my application remotely via jconsole. It works locally, but when I deploy my application to a Linux machine, it gets time.

I use Daemon to run my environment.

this is what i add to the run.sh script:

-Dcom.sun.management.jmxremote \ -Dcom.sun.management.jmxremote.port=6969 \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun.management.jmxremote.authenticate=false \ com.mypackage.daemon.FixDaemon 

and inside applicationContext.xml:

 <context:mbean-server /> <context:mbean-export /> 

now on linux machine after running netstat, what we see:

 [ root@ logs]# netstat -an | grep 6969 tcp 0 0 :::6969 :::* LISTEN 

therefore it seems that he is listening.

but when I add my ip: 6969 inside the jconsole interface, I get a popup with an error message.

any idea what am i doing wrong?

thanks, rays.

+4
source share
2 answers

First try adding this option to your application:

-Djava.rmi.server.hostname=<ip>

Also keep in mind that jconsole uses RMI for communication. This means that jconsole first connects to ip: 6969. Then the server generates a random port X, which is passed back to jconsole. Jconsole then opens another connection to ip: X. Since X is random, you cannot open this particular port in the firewall. You must either open all ports or use the socks proxy, which is another object.

+5
source
  • Try connecting to this port using telnet from your computer. If this fails, this usually happens due to firewall packets. You need to talk to your network administrator to open this port.

    Note You will need to open two ports. One for binding RMIRegistry and one for exporting RMI objects. RMI typically exports objects on random high ports. But this will not work in a firewall environment, so you will need to configure the port on which it is exported. This is done using the RMI URL.

  • If you use this on Linux, run hostname -i if it returns 127.0.0.1, then fix /etc/hosts . The FAQ section for JConsole provides more information about this.

  • Another option that I would highly recommend is to view Jolokia , which is not related to changing the firewall configuration, but still provides JMX compared to HTTP.

+1
source

All Articles