简体   繁体   English

如何调试 ngrok 隧道暴露的远程 JVM

[英]How to debug remote JVM exposed by ngrok tunnel

I have a java process on one of my machines listening on port 4502. I have created a tunnel using ngrok so that I can access the application on my development machine.我的其中一台机器上有一个 java 进程,监听端口 4502。我使用 ngrok 创建了一个隧道,以便我可以访问我的开发机器上的应用程序。 The issue I'm facing is attaching a debugger to the remote JVM.我面临的问题是将调试器附加到远程 JVM。

Here is the debug java configuration I'm using:这是我正在使用的调试 java 配置:

-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=n

Here is the ngrok configuration for the tunnel to the application:这是应用程序隧道的 ngrok 配置:

ngrok http 4502

Here is the ngrok configuration for the tunnel to the JVM (I have also tried http protocol with no luck):这是到 JVM 的隧道的 ngrok 配置(我也尝试过 http 协议,但没有成功):

ngrok tcp 5005

ngrok outputs the following for the tcp tunnel: ngrok 为 tcp 隧道输出以下内容:

Forwarding tcp://2.tcp.eu.ngrok.io:10928 -> 127.0.0.1:5005

Using IntelliJ, I configure the remote debugging like this:使用 IntelliJ,我像这样配置远程调试:

Debugger mode: Attach to remote JVM
Host: tcp://2.tcp.eu.ngrok.io
Port: 10928

I get the following error when starting the debugger:启动调试器时出现以下错误:

Error running 'Debug Author Desktop': Unable to open debugger port (tcp://2.tcp.eu.ngrok.io:10928): java.io.IOException "handshake failed - connection prematurally closed"运行“调试作者桌面”时出错:无法打开调试器端口 (tcp://2.tcp.eu.ngrok.io:10928):java.io.IOException“握手失败 - 连接过早关闭”

On the machine running the java process, I have made sure that the 5005 port is open before starting the process.在运行 java 进程的机器上,我确保在启动进程之前 5005 端口是打开的。 On the machine using IntelliJ, I have made sure that the 10928 port is open.在使用 IntelliJ 的机器上,我确保 10928 端口已打开。 What must I do so that I can attach the debugger to the process running on my second machine?我必须做什么才能将调试器附加到在我的第二台机器上运行的进程? Any help would be appreciated.任何帮助,将不胜感激。

I've found the solution.我找到了解决方案。 The issue was in the Remote Debugger configuration.问题出在远程调试器配置中。 When specifying the host, you must not include the protocol.指定主机时,不得包含协议。 Once I changed tcp://2.tcp.eu.ngrok.io to 2.tcp.eu.ngrok.io , it worked!一旦我将tcp://2.tcp.eu.ngrok.io更改为2.tcp.eu.ngrok.io ,它就起作用了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM