1

I have a typical in-house cluster with a login node and multiple compute nodes. For a start, I ran a JVM instance with the following params to let my IntelliJ debugger connect to it.

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

This login node has a pubically accessible address which I mostly ssh into to launch jobs. However, when I try to attach my IntelliJ debugger to a JVM instance on this node, the connection just times it and it is unable to connect while my JVM instance is indeed launched in the suspended mode waiting for the debugger to connect to it.

IntelliJ Remote debug configuration

Update: The initial problem seemed to be that I get not access any other port on my server other than port 22 which I use to SSH into it. Anyhow, I was able to create a SOCK5 proxy, configured IntelliJ to use that proxy and then successfully test the connection as well as shown below:

Testing the connection at the host:port the debugger is listenning at

The output on the debugger console shows that IntelliJ was successfully able to access that port on the specified hostname, albiet with an HTTP request and not a JWP one.

Debugger console output

However, when I then proceed to connect the debugger to the same host:port combination, I am unable to do so and get the following error:

Debugger error

I have also tried setting suspend=n but to no avail.

jaywalker
  • 1,116
  • 4
  • 26
  • 44
  • Can you telnet to the specified address/port from the machine where IntelliJ IDEA is running? If not, it's a firewall/networking issue that has nothing to do with the IDE. – CrazyCoder Aug 25 '17 at 21:48
  • Like described [here](https://stackoverflow.com/questions/975271/remote-debugging-a-java-application), try starting the JVM with `suspend=n`. – Sam Aug 26 '17 at 08:10
  • @CrazyCoder, Please check out the updates I made to the original question. – jaywalker Aug 28 '17 at 00:00
  • @Sam, tried while setting suspend=n. Makes no difference. – jaywalker Aug 28 '17 at 00:01
  • @HaseebJaved I don't think debugger can use proxy configuration in IntelliJ IDEA, you can set up SSH tunnel as a workaround. – CrazyCoder Aug 28 '17 at 00:02
  • @CrazyCoder I already have an SSH tunnel created, do you mean I just force IntelliJ to use default system proxy settings by enabling `Auto-detect proxy` in `Appearance & Behavior -> System Settings -> HTTP Proxy`? – jaywalker Aug 28 '17 at 00:07
  • @HaseebJaved no, use the tunnel port open on localhost that redirects the connection to your remote host. In IntelliJ IDEA you will connect to localhost and the tunnel port instead of the remote host/port. – CrazyCoder Aug 28 '17 at 00:09
  • @CrazyCoder Just to be sure I understand you correctly: I am creating the tunnel using the command `ssh -D8080 haseeb@myserver.com` so my tunnel port is `8080`. Now in the Remote Debug configuration for the IntelliJ debugger, I set `Host: localhost` and `Port: 8080`. Tried this but still the same issue. – jaywalker Aug 28 '17 at 00:26
  • @HaseebJaved no, debugger port is 5005 on the remote according to your screenshots. 8080 is probably the web port of your app which has no relation to the debugger. – CrazyCoder Aug 28 '17 at 00:27
  • @CrazyCoder I am a bit lost. `8088` is definitely my tunnely port becuase that is the port I use to create the SOCK proxy using the command `ssh -D 8080 haseeb@myserver.com`. I can modify this port to any other as well. However, when you say: ` In IntelliJ IDEA you will connect to localhost and the tunnel port instead of the remote host/port.` do you mean connect the debugger in IntelliJ to the tunnel port or the proxy settings in IntelliJ to the tunnel port. If it is the latter then I think that is exactly what I have been doing in the screenshot. – jaywalker Aug 28 '17 at 00:39
  • 1
    `ssh -L 5005:localhost:5005 haseeb@myserver.com` will map `localhost:5005` to port 5005 on myserver.com (also on localhost interface of myserver.com). This way in IntelliJ IDEA debugger you will be connecting to `localhost` (specify it in the Host field) port 5005 and the connection will be forwarded to the remote server where debugger listens on `localhost:5005`. See [here](http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html) for more details how SSH tunnels work. – CrazyCoder Aug 28 '17 at 00:44
  • I was creating a SOCK proxy by passing the `-D` flag but you very simply referring to forwarding a port in the local system to a host:port on the remote server using the `-L` flag. This works, thanks a bunch! – jaywalker Aug 28 '17 at 01:02

1 Answers1

5

ssh -L 5005:localhost:5005 haseeb@myserver.com

will map localhost:5005 to port 5005 on myserver.com (also on localhost interface of myserver.com). This way in IntelliJ IDEA debugger you will be connecting to localhost (specify it in the Host field) port 5005 and the connection will be forwarded to the remote server where debugger listens on localhost:5005.

See here for more details how SSH tunnels work

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904