Unable to remotely connect to JMX?
Solution 1:
Add -Djava.rmi.server.hostname = host ip
. Even i faced the same problem and this did the trick.
Addition of this -Djava.rmi.server.hostname = host ip
forces RMI service to use the host ip instead of 127.0.0.1
Solution 2:
These are the steps that worked for me (Debian behind firewall on the server side was reached over VPN from my local Mac):
-
Check server public ip
ifconfig
Use JVM params:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=[jmx port]
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=[server ip from step 1]
Run application
Find process ID of the running java process
-
Check all ports used by JMX/RMI
netstat -lp | grep [pid from step 4]
Open all ports from step 5 on the firewall
Voila.
Solution 3:
In addition to listening to the port you specified (1100) the JMX server also listens to a randomly chosen (ephemeral) port. Check, e.g. with lsof -i|grep java
if you are on linux/osx, which ports the java process listens to and make sure your firewall is open for the ephemeral port as well.
Solution 4:
I experienced the problem where it said 'Adding ' forever and didn't seem to be able to connect. I got passed the problem by changing the jvisualvm proxy settings (Tools->options->network). Once I changed the option to No Proxy, I was able to connect. My jvm was started with the following options:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=2222
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=<external_IP_of_server>
Then when I added the jmx connection, I specified "external_IP_of_server:2222"
Solution 5:
I had a similar issue when using port forwarding.
I have a remote machine with Tomcat listening for JMX interactions on localhost:9000
.
From my local machine, I'm used to do port-forwarding with:
ssh -L 9001:localhost:9000 tomcat.example.com
(so remote port 9000 is forwarded to my local machine's port 9001).
Then when I tried to use VisualVM to connect to localhost:9001
, the connection was refused. JMX seems to require port numbers on both sides to be identical.
So my solution was using port numbers 9000 and 9000:
ssh -L 9000:localhost:9000 tomcat.example.com
Now my local machine's VisualVM connects successfully to the remote machine's Tomcat via localhost:9000
.
Make sure that you don't have any other service (Tomcat on dev machine?) listening on the same port.
Also take a look at setting up parameters correctly.