Search code examples
javaamazon-web-servicesamazon-ecsjmxaws-fargate

AWS Fargate - From local Unable to connect to jmx port of java application running on aws fargate


This is what I have done so far:

  1. I have deployed a java 11 application on aws fargate and it is up and running.
  2. Task definition is correctly configured for tcp port mapping to application port and jmx port (3939).
  3. There is VPC configuration which allows communication between my network and aws.
  4. Application is started with these additional system properties for remote jmx connections:
    -Dcom.sun.management.jmxremote.port=3939
    -Dcom.sun.management.jmxremote.ssl=false 
    -Dcom.sun.management.jmxremote.authenticate=false
    
  5. From my local machine I am successfully able to telnet to private IP of fargate task and jmx port 3939.

But when I am trying to connect to jmx using JVisualVm or JDK mission control it is unable to connect. Am I missing something here ?


Solution

  • Finally it worked after I added below mentioned property which forces rmi port to be same as jmx port instead of opening a random port which was not opened from security group.

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

    Thanks to these stackoverflow posts:

    Why Java opens 3 ports when JMX is configured?

    Remote monitoring with visualvm and JMX