简体   繁体   中英

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. The issue I'm facing is attaching a debugger to the remote JVM.

Here is the debug java configuration I'm using:

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

Here is the ngrok configuration for the tunnel to the application:

ngrok http 4502

Here is the ngrok configuration for the tunnel to the JVM (I have also tried http protocol with no luck):

ngrok tcp 5005

ngrok outputs the following for the tcp tunnel:

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

Using IntelliJ, I configure the remote debugging like this:

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"

On the machine running the java process, I have made sure that the 5005 port is open before starting the process. On the machine using IntelliJ, I have made sure that the 10928 port is open. 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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