Connection error jmcon java jQuon

I am trying to connect jconsole to jvm called:

java \ -Djava.util.logging.config.file=./logging.properties \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun.management.jmxremote.authenticate=false \ -Dcom.sun.management.jmxremote.port=12700 \ -cp . Sleep 

Then I try to start jconsole with:

 jconsole -J-Djava.util.logging.config.file=./logging.properties 

The loggin.properties file includes:

 sun.rmi.level=FINEST 

After opening the socket on port 12700, rmi will then try to connect to another port:

 FINER: [javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi:///jndi/rmi://10.40.243.12:12700/jmxrmi] connecting... Jan 5, 2012 2:30:42 PM RMIConnector connect FINER: [javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi:///jndi/rmi://10.40.243.12:12700/jmxrmi] finding stub... Jan 5, 2012 2:30:43 PM sun.rmi.transport.tcp.TCPEndpoint <clinit> FINE: JConsole.addHost: localHostKnown = true, localHost = 10.206.6.59 Jan 5, 2012 2:30:43 PM sun.rmi.server.UnicastRef newCall FINE: JConsole.addHost: get connection Jan 5, 2012 2:30:43 PM sun.rmi.transport.tcp.TCPTransport <init> FINE: JConsole.addHost: Version = 2, ep = [10.206.6.59:0] Jan 5, 2012 2:30:43 PM sun.rmi.transport.tcp.TCPEndpoint getLocalEndpoint FINE: JConsole.addHost: created local endpoint for socket factory null on port 0 Jan 5, 2012 2:30:43 PM sun.rmi.transport.tcp.TCPChannel createConnection FINE: JConsole.addHost: create connection Jan 5, 2012 2:30:43 PM sun.rmi.transport.tcp.TCPEndpoint newSocket FINER: JConsole.addHost: opening socket to [10.40.243.12:12700] Jan 5, 2012 2:30:43 PM sun.rmi.transport.proxy.RMIMasterSocketFactory createSocket FINE: JConsole.addHost: host: 10.40.243.12, port: 12700 Jan 5, 2012 2:30:43 PM sun.rmi.transport.tcp.TCPChannel createConnection FINER: JConsole.addHost: server suggested 10.206.6.59:12306 Jan 5, 2012 2:30:43 PM sun.rmi.transport.tcp.TCPChannel createConnection FINER: JConsole.addHost: using 10.206.6.59:0 Jan 5, 2012 2:30:43 PM sun.rmi.server.UnicastRef newCall FINER: JConsole.addHost: create call context Jan 5, 2012 2:30:43 PM sun.rmi.server.UnicastRef logClientCall FINER: JConsole.addHost: outbound call: [endpoint:[10.40.243.12:12700](remote),objID:[0:0:0, 0]] : sun.rmi.registry.RegistryImpl_Stub[0:0:0, 0]: java.rmi.Remote lookup(java.lang.String) Jan 5, 2012 2:30:43 PM sun.rmi.transport.StreamRemoteCall <init> FINER: JConsole.addHost: write remote call header... Jan 5, 2012 2:30:43 PM sun.rmi.transport.StreamRemoteCall getOutputStream FINER: JConsole.addHost: getting output stream Jan 5, 2012 2:30:43 PM sun.rmi.server.UnicastRef invoke FINER: JConsole.addHost: execute call Jan 5, 2012 2:30:43 PM sun.rmi.transport.StreamRemoteCall getInputStream FINER: JConsole.addHost: getting input stream Jan 5, 2012 2:30:43 PM sun.rmi.server.LoaderHandler loadClass FINE: JConsole.addHost: name = "javax.management.remote.rmi.RMIServerImpl_Stub", codebase = "", defaultLoader = sun.misc.Launcher$AppClassLoader@a39137 Jan 5, 2012 2:30:43 PM sun.rmi.server.LoaderHandler loadClass FINER: JConsole.addHost: class "javax.management.remote.rmi.RMIServerImpl_Stub" found via defaultLoader, defined by null Jan 5, 2012 2:30:43 PM sun.rmi.server.LoaderHandler loadClass FINE: JConsole.addHost: name = "java.rmi.server.RemoteStub", codebase = "", defaultLoader = sun.misc.Launcher$AppClassLoader@a39137 Jan 5, 2012 2:30:43 PM sun.rmi.server.LoaderHandler loadClass FINER: JConsole.addHost: class "java.rmi.server.RemoteStub" found via defaultLoader, defined by null Jan 5, 2012 2:30:43 PM sun.rmi.server.LoaderHandler loadClass FINE: JConsole.addHost: name = "java.rmi.server.RemoteObject", codebase = "", defaultLoader = sun.misc.Launcher$AppClassLoader@a39137 Jan 5, 2012 2:30:43 PM sun.rmi.server.LoaderHandler loadClass FINER: JConsole.addHost: class "java.rmi.server.RemoteObject" found via defaultLoader, defined by null Jan 5, 2012 2:30:43 PM sun.rmi.server.UnicastRef done FINE: JConsole.addHost: free connection (reuse = true) Jan 5, 2012 2:30:43 PM sun.rmi.transport.tcp.TCPChannel free FINE: JConsole.addHost: reuse connection Jan 5, 2012 2:30:43 PM sun.rmi.transport.tcp.TCPChannel free FINE: JConsole.addHost: create reaper Jan 5, 2012 2:30:43 PM sun.rmi.server.UnicastRef newCall FINE: JConsole.addHost: get connection Jan 5, 2012 2:30:43 PM sun.rmi.transport.tcp.TCPChannel createConnection FINE: JConsole.addHost: create connection Jan 5, 2012 2:30:43 PM sun.rmi.transport.tcp.TCPEndpoint newSocket FINER: JConsole.addHost: opening socket to [tdiap12:41096] Jan 5, 2012 2:30:43 PM sun.rmi.transport.proxy.RMIMasterSocketFactory createSocket FINE: JConsole.addHost: host: tdiap12, port: 41096 

The first connection attempt succeeds because on the remote server I see an ESTABLISHED connection.

 wse2tst@tdiap12 :~> netstat -a | grep 12700 tcp 0 0 *:12700 *:* LISTEN tcp 0 0 tdiap12.vgcar.net:12700 per-00c0016253a2.vgca:12252 ESTABLISHED 

Packet tracing also indicates a successful connection.

The second connection to the port is 41096 times, and the jconsole application reports a Connection Failure error and terminates the first connection. Why is the second connection done? Can I specify a port for this second connection? The target server is tightly controlled, and other ports are blocked by firewall rules. When attempting a multiple connection, the second port will change to different random values.

Thanks for any help, Steve.

+4
source share
3 answers

The implemented JMX implementation uses two ports: one for the registry (the one you specified), and one for the actual connection, which is randomly selected (!). This is a fairly constructive flaw, as randomly selecting a second port makes it very difficult to configure a firewall.

However, there are ways around this: either you can do it yourself manually , or if you use Tomcat, you let it handle it for you .

+7
source

A new and better solution than using a manually encoded agent is to use a new parameter that seems to be introduced in Java 7:

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

Thus, in combination - you can use the same port:

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

The solution is found here: http://hirt.se/blog/?p=289

+5
source

You can set the second port with the parameter - "Dcom.sun.management.jmxremote.rmi.port", where the port number can be the same as the number of the first. Even after installing this, there will be traffic jams for an insecure connection ... please allow an insecure connection, then only it will allow you to continue, otherwise until then in the log you will find that the error failed to connect: java.lang.SecurityException: Waiting for sun. rmi.server.UnicastRef2 remote link in the stub!

thanks

0
source

Source: https://habr.com/ru/post/1389363/


All Articles