I am trying to connect to my remote server using VisualVM but the JMX connection just hangs with timeout. Although I can access from my local machine the port using telnet “public server IP:8070”
The Dockerfile of the project looks like this:
FROM zulu-openjdk-alpine:11-jre
....
ENV JAVA_DEFAULT_OPTIONS='-server -dsa -XX:+PrintCommandLineFlags
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8070
-Dcom.sun.management.jmxremote.rmi.port=8070
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname='<public server IP>'
EXPOSE 8070
ENTRYPOINT java -cp $MY_PROJECT_CLASSPATH $JAVA_DEFAULT_OPTIONS $MY_PROJECT_START_CLASS
I exposed the port form the container using service:
kind: Service
apiVersion: v1
metadata:
name: my-project-jmx
spec:
ports:
- name: tcp-32070
protocol: TCP
port: 32070
targetPort: 8070
nodePort: 32070
externalTrafficPolicy: Local
type: LoadBalancer
selector:
app: my-project
type: NodePort