How do check if someone is connected to debug port, or is actively debugging

1.6k views Asked by At

We have a Tomcat7 Java 11 application on which a few developers work in parallel. This has some debug ports exposed in DEV stability. Sometimes, a user might connect to the debug port and end up forgetting to close the connection, and leaves the connection open, with some active debug points causing the application to pause all processing which involves that flow.

I was wondering if the following options are possible:

  • Use JMX or even custom Java code which can be exposed restfully on Tomcat to check is someone is actively debugging (to be clear, I don't mean if debug options are enabled, but if someone is actually connected to that port)
  • Get username or some identification for the user. Maybe the machine from which connection request originated?
  • Automatically close debug connection after some fixed time?
1

There are 1 answers

0
Dmytro Kopan On BEST ANSWER

If you have app running on Linux

  • Go to terminal,
  • Run ss -tn src :debugPort
  • Under Peer Address:Port you will find the host connected to your app.
  • Then use tcpkill ip host 192.168.1.2 to end the connection.