Does Java 6 open a default port for JMX remote connections?

前端 未结 7 1074
终归单人心
终归单人心 2020-12-07 09:46

My specific question has to do with JMX as used in JDK 1.6: if I am running a Java process using JRE 1.6 with

com.sun.management.jmxremote

7条回答
  •  执念已碎
    2020-12-07 10:17

    So, the short answer to my question is "no."

    However, it's interesting to examine why. Look at the netstat output from a valid local connection. Here are the ports that I see opened up as a result of a jconsole making a local connection to itself. As you can see, port 1650 is the local port being used for the JMX information:

    Proto  Local Address          Foreign Address        State
    TCP    Gandalf:1650           Gandalf:1652           ESTABLISHED
    TCP    Gandalf:1650           Gandalf:1653           ESTABLISHED
    TCP    Gandalf:1650           Gandalf:1654           ESTABLISHED
    TCP    Gandalf:1650           Gandalf:1655           ESTABLISHED
    TCP    Gandalf:1650           Gandalf:1656           ESTABLISHED
    TCP    Gandalf:1652           Gandalf:1650           ESTABLISHED
    TCP    Gandalf:1653           Gandalf:1650           ESTABLISHED
    TCP    Gandalf:1654           Gandalf:1650           ESTABLISHED
    TCP    Gandalf:1655           Gandalf:1650           ESTABLISHED
    TCP    Gandalf:1656           Gandalf:1650           ESTABLISHED
    

    However, it's not sufficient to try to connect jconsole to localhost:1650. Sadly, all that will net you is a "Connection failed: no such object in table" message.

    So, the conclusion of my original story is that, if we are going to facilitate remote monitoring using JMX for our customers, we really need to identify unique individual remote access ports for the variety of Java processes that are started in our system. Fortunately, all this requires is the judicious use of the VM argument:

    com.sun.management.jmxremote.port=portNum
    

    where we will almost certainly have a sequential pre-specified range of portNum so that the customer can select the correct remote application using the port number.

提交回复
热议问题