VisualVM cannot profile; connects and other tabs work but Sampler tab gives:"Failed to create JMX connection"

StackOverflow https://stackoverflow.com/questions/17221474

Question

I'm trying to use VisualVM to profile an app running in EC2. VisualVM connects to the remote machine and will show me the Overview, Monitor and VisualGC tabs (with data), but when I select the Sampler tab I get:

Not available. Failed to create JMX connection to target application. Use 'Add JMX Connection' action to attach to the application.

I've tried adding the JMX connection (to the EC2 public address, and the JMX port that the app was started with) to no avail.

I can see in the VisualVM Overview tab that I've set the app's jmxsettings (and by extension that VisualVM sees those settings):

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9010
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false

I'm using an EC2 security model that leaves all ports open from EC2 to my local machine. I'm running the exact same JVM on both machines. I've run jstatd on the EC2 machine.

Not sure what else to try.

Was it helpful?

Solution

Do you use SSL authentication? If don't want to use it, try to replace

-Dcom.sun.management.jmxremote.local.only=false

with

-Dcom.sun.management.jmxremote.ssl=false

OTHER TIPS

Brian,

You can connect to EC2 JMX port from your local jvisualvm without opening EC2 JMX port. The way I do it is using ssh tunnel. Run below command on your local computer:

ssh -i <aws .pem key>  ec2-user@<ec2-ip> -v -D 9010

And then in jvisualvm, go to Tools --> Options --> Network and select Manual proxy settings and input below:

Socks Proxy:  localhost  Port: 9010

Under No Proxy Hosts keep nothing and click OK.

Then select localhost and right click Add JMX Connection and input localhost:9010 and you are done :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top