0

I have a Springboot application being successfully deployed in a Docker container and I am trying to connect JConsole to it. Inside the container the application is being executed with the following flags:

-Dcom.sun.management.jmxremote
-Djava.rmi.server.hostname="$JMX_RMI_SERVER_HOST"
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=10122
-Dcom.sun.management.jmxremote.rmi.port=10122

where JMX_RMI_SERVER_HOST=$(hostname -i).

In my Dockerfile I have EXPOSE 10122 and in the ports section of my compose 10122:10122.

JConsole fails to connect to localhost:10122 most likely because of this warning that I see in my logs:

15:40:35.896 [RMI TCP Accept-0] [] [] [] WARN  sun.rmi.transport.tcp - RMI TCP Accept-0: accept loop for ServerSocket[addr=0.0.0.0/0.0.0.0,localport=44567] throws
java.net.SocketTimeoutException: Accept timed out
    at java.base/java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.base/java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:458)
    at java.base/java.net.ServerSocket.implAccept(ServerSocket.java:551)
    at java.base/java.net.ServerSocket.accept(ServerSocket.java:519)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:394)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:366)
    at java.base/java.lang.Thread.run(Thread.java:834)
15:40:35.896 [RMI TCP Accept-10122] [] [] [] WARN  sun.rmi.transport.tcp - RMI TCP Accept-10122: accept loop for ServerSocket[addr=0.0.0.0/0.0.0.0,localport=10122] throws
java.net.SocketTimeoutException: Accept timed out
    at java.base/java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.base/java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:458)
    at java.base/java.net.ServerSocket.implAccept(ServerSocket.java:551)
    at java.base/java.net.ServerSocket.accept(ServerSocket.java:519)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:394)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:366)
    at java.base/java.lang.Thread.run(Thread.java:834)

Does anyone know what I am missing? Thank you for your help

João Matos
  • 6,102
  • 5
  • 41
  • 76
  • Are you sure `$JMX_RMI_SERVER_HOST` points to the host/ip where you launched `docker run` ? This [other question](https://stackoverflow.com/questions/31257968/how-to-access-jmx-interface-in-docker-from-outside) might help – Zeitounator Dec 16 '19 at 16:07
  • I believe that $JMX_RMI_SERVER_HOST should be the ip address of the container and not the host machine. Anyway, I did try to put 0.0.0.0 just in case (note that I am running the container in my local machine), but with the same result. – João Matos Dec 16 '19 at 16:09
  • Did you have a look the other question ? The accepted answer is saying the exact opposite (unless I did not read well). – Zeitounator Dec 16 '19 at 16:11
  • Yes I did, and I believe it is not supposed to be the host's IP. Anyway, I tried the host IP address and the result was the same – João Matos Dec 16 '19 at 16:23

0 Answers0