如何检查某人是否连接到调试端口,或者是否正在进行调试。

huangapple go评论75阅读模式
英文:

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

问题

我们有一个运行在Tomcat7上的Java 11应用程序,有几个开发人员并行工作。在DEV环境中,一些调试端口是公开的。有时,用户可能会连接到调试端口,然后忘记关闭连接,导致连接保持打开状态,并且一些活动的调试点导致应用程序暂停所有涉及该流程的处理。

我想知道以下选项是否可行:

  • 使用JMX或甚至自定义的Java代码,可以在Tomcat上以REST方式公开,以检查是否有人正在活动调试(明确一下,我不是指调试选项是否已启用,而是是否有人实际连接到该端口)。
  • 获取用户名或一些用户标识。也许是连接请求起源的机器?
  • 在固定时间后自动关闭调试连接?
英文:

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

得分: 1

如果您的应用程序在Linux上运行

  • 打开终端,
  • 运行 ss -tn src :debugPort
  • 在“Peer Address:Port”下,您将找到连接到您的应用程序的主机。
  • 然后使用 tcpkill ip host 192.168.1.2 终止连接。
英文:

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.

huangapple
  • 本文由 发表于 2020年10月8日 16:11:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/64258390.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定