Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Couldnt connect to JMX remote with jconsole

I developing under Spring3.1 standalone env.

I am trying to connect my application remotely via jconsole. It's working locally but when I deploy my application into the linux machine it gets time out.

I am using Daemon in order to run my environment.

this is what I add in the run.sh script:

-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=6969 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
com.mypackage.daemon.FixDaemon

and inside applicationContext.xml:

<context:mbean-server />
<context:mbean-export />

now on the linux machine after doing netstat thats what we see:

[root@ logs]# netstat -an | grep 6969
tcp        0      0 :::6969                     :::*                        LISTEN

so it's seems like it does listening.

but when I add my ip:6969 inside the jconsole interface I get connection failed popup.

any idea what am I doing wrong?

thanks, ray.

like image 550
rayman Avatar asked Feb 19 '23 09:02

rayman


1 Answers

First try to add also this option to your application:

-Djava.rmi.server.hostname=<ip>

Also keep in mind jconsole is using RMI for the communication. This means jconsole first connects to ip:6969. Then server generates a random port X which is passed back to the jconsole. Jconsole then opens another connection to ip:X. Since X is random, there is no way you can open this specific port in the firewall. You have either to open all ports or use a socks proxy which is another subject.

like image 165
mrembisz Avatar answered Feb 23 '23 00:02

mrembisz