Java 应用程序打印“在地址:5005 处侦听传输 dt_socket”并且不会停止

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38426043/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 20:20:05  来源:igfitidea点击:

Application prints "Listening for transport dt_socket at address: 5005" and does not halt

javadebuggingremote-debugging

提问by MiamiBeach

I start code execution with the typical arguments:

我使用典型参数开始代码执行:

java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 myPackage.myMainClassname

Application starts, prints "Listening for transport dt_socket at address: 5005" and... goes further! Without any attempt to wait for connection. I CAN connect to it during execution and debugging itself works. But why does the application not wait for connection from debugger?

应用程序启动,打印“Listening for transport dt_socket at address: 5005”,然后……更进一步!没有任何尝试等待连接。我可以在执行期间连接到它,并且调试本身可以工作。但是为什么应用程序不等待来自调试器的连接?

Looks like something is broken in my configuration, but I cannot figure out the root cause. I tried several ways to specify debug settings, different ports, run as administrator, turn off firewalls - nothing helps.

看起来我的配置有问题,但我无法找出根本原因。我尝试了几种方法来指定调试设置、不同的端口、以管理员身份运行、关闭防火墙 - 没有任何帮助。

采纳答案by Alexandar Petrov

You need to specify suspend=yif you want it to wait for connection. Your debugging is working. If you try to connect you will be able to. Most probably you are just used to using suspend=ywhich blocks until the connection is established.

您需要指定suspend=y是否希望它等待连接。您的调试工作正常。如果您尝试连接,您将能够连接。很可能您只是习惯于在suspend=y建立连接之前使用哪些块。

The behavior is expected when suspend=n.

suspend=n.

回答by Igor Bykov

Select menu "Run/Edit Configurations". Check: "Edit configurations" dialog pops up. Click on "+" icon, select "Remote" from the list. Check: new configuration with name "Unnamed" appears under "Remote" category. Change configuration name to something more sensible, like "Remote Debug". Don't change any other parameters, just click "OK".

Run web-application under the debugger

Start gradle task "appStartDebug" under IntelliJ IDEA. Attention: do not try to start this task under the debugger. Run it in normal mode. Check: you should see "Listening for transport dt_socket at address: 5005" in "Run" output window. Select menu "Run/Run...", select "Remote Debug" configuration, select "Debug" command. Check: you should see "Connected to the target VM, address: 'localhost:5005', transport: 'socket'" in "Debug" output window.

选择菜单“运行/编辑配置”。检查:弹出“编辑配置”对话框。单击“+”图标,从列表中选择“远程”。检查:名称为“未命名”的新配置出现在“远程”类别下。将配置名称更改为更合理的名称,例如“远程调试”。不要更改任何其他参数,只需单击“确定”。

在调试器下运行 web-application

在 IntelliJ IDEA 下启动 gradle 任务“appStartDebug”。注意:不要尝试在调试器下启动此任务。在正常模式下运行它。检查:您应该在“运行”输出窗口中看到“在地址:5005 处侦听传输 dt_socket”。选择菜单“Run/Run...”,选择“Remote Debug”配置,选择“Debug”命令。检查:您应该在“调试”输出窗口中看到“已连接到目标 VM,地址:'localhost:5005',传输:'socket'”。

Now your web-application is running under the debugger: you can set breakpoints, watch/inspect variables etc.etc.

现在您的 Web 应用程序正在调试器下运行:您可以设置断点、观察/检查变量等。