Remote JMX connection

前端 未结 12 922
后悔当初
后悔当初 2020-11-29 15:54

I\'m trying to open a JMX connection to java application running on a remote machine.

The application JVM is configured with the following options:

  • com
相关标签:
12条回答
  • 2020-11-29 16:02

    I know this thread is pretty old, but there's an additional option that will help greatly. See here: https://realjenius.com/2012/11/21/java7-jmx-tunneling-freedom/

    -Dcom.sun.management.jmxremote.rmi.port=1099

    0 讨论(0)
  • 2020-11-29 16:04

    In my testing with Tomcat and Java 8, the JVM was opening an ephemeral port in addition to the one specified for JMX. The following code fixed me up; give it a try if you are having issues where your JMX client (e.g. VisualVM is not connecting.

    -Dcom.sun.management.jmxremote.port=8989
    -Dcom.sun.management.jmxremote.rmi.port=8989
    

    Also see Why Java opens 3 ports when JMX is configured?

    0 讨论(0)
  • 2020-11-29 16:08

    it seams that your ending quote comes too early. It should be after the last parameter.

    This trick worked for me.

    I noticed something interesting: when I start my application using the following command line:

    java -Dcom.sun.management.jmxremote.port=9999
         -Dcom.sun.management.jmxremote.authenticate=false
         -Dcom.sun.management.jmxremote.ssl=false
    

    If I try to connect to this port from a remote machine using jconsole, the TCP connection succeeds, some data is exchanged between remote jconsole and local jmx agent where my MBean is deployed, and then, jconsole displays a connect error message. I performed a wireshark capture, and it shows data exchange coming from both agent and jconsole.

    Thus, this is not a network issue, if I perform a netstat -an with or without java.rmi.server.hostname system property, I have the following bindings:

     TCP    0.0.0.0:9999           0.0.0.0:0              LISTENING
     TCP    [::]:9999              [::]:0                 LISTENING
    

    It means that in both cases the socket created on port 9999 accepts connections from any host on any address.

    I think the content of this system property is used somewhere at connection and compared with the actual IP address used by agent to communicate with jconsole. And if those address do not match, connection fails.

    I did not have this problem while connecting from the same host using jconsole, only from real physical remote hosts. So, I suppose that this check is done only when connection is coming from the "outside".

    0 讨论(0)
  • 2020-11-29 16:08

    Try using ports higher than 3000.

    0 讨论(0)
  • 2020-11-29 16:10

    http://blogs.oracle.com/jmxetc/entry/troubleshooting_connection_problems_in_jconsole

    If you are trying to access a server which is behind a NAT - you will most probably have to start your server with the option

    -Djava.rmi.server.hostname=<public/NAT address>
    

    so that the RMI stubs sent to the client contain the server's public address allowing it to be reached by the clients from the outside.

    0 讨论(0)
  • 2020-11-29 16:10

    I have the same issue and I change any hostname that matches the local host name to 0.0.0.0, it seems to work after I do that.

    0 讨论(0)
提交回复
热议问题