cp5
cp5

Reputation: 61

Remote Debugging of Openshift Application in Intellij-Idea

I have a java application running on an openshift remote cluster and I want to debug the app from my local machine with Intellij-Idea. The app is built by a Jenkinsfile on another remote jenkins server (gradle build, docker build and pushed to openshift, where it is automatically deployed).

The Dockerfile exposes port 9009 and therefore my Intellij Remote Debug Config looks like this: Debug Config

With the localhost in the Debug Config I need openshift port-forwarding:

oc port-forward my-pod 9009
Forwarding from 127.0.0.1:9009 -> 9009

When I start the Debugger I get the following error in Intellij:

Error running 'DTC Remote Debug':
Unable to open debugger port (localhost:9009): java.net.ConnectException "Connection refused: connect"

At the same time the terminal with the port forwarding shows:

Handling connection for 9009
E0927 09:52:33.711817   5996 portforward.go:331] an error occurred forwarding 9009 -> 9009: error forwarding port 9009 to pod ad370...c010, uid : exit status 1: 2019/09/27 03:52:33 socat[129691] E connect(5, AF=2 127.0.0.1:9009, 16): Connection refused

Doing an Nmap scan against the url where I get the index.html of my application I got the following:

nmap -sS my-openshift-url
Starting Nmap 7.80 ( https://nmap.org ) at 2019-09-27 15:01 Mitteleuropõische Sommerzeit
Nmap scan report for my-openshift-url (IP-Address)
Host is up (0.0043s latency).
rDNS record for IP-Address: dispatch-my-domain
Not shown: 997 filtered ports
PORT     STATE  SERVICE
80/tcp   open   http
443/tcp  open   https
9009/tcp closed pichat

Nmap done: 1 IP address (1 host up) scanned in 6.10 seconds

I guess the problem is the closed 9009 port, but I have no clue how I can open that port on my openshift cluster. I already set several environment variables in the openshift web UI (just to be sure):

DEBUG            TRUE
DEBUG            true
DEBUGGING        TRUE
DEBUGGING        true
JAVA_DEBUG       TRUE
JAVA_DEBUG       true
JAVA_DEBUG_PORT  9009

But I can't get it to work. If I switch the port-forwarding to 8080 I can access the index.html via localhost:8080 from my browser. I don't know if I need to change something in the project code (gradle, docker, jenkins, etc.) or if I can just open the port on the deployed service in openshift somehow...

If anything isn't clear or if I missed something just tell me. I'm happy for every piece of advice.

Regards,

Christoph

Upvotes: 2

Views: 5873

Answers (1)

cp5
cp5

Reputation: 61

Adding the following environment variable in openshift did the trick:

JAVA_TOOL_OPTIONS   -agentlib:jdwp=transport=dt_socket,address=9009,server=y,suspend=n

All the other environment variables from above are absolete...

Upvotes: 4

Related Questions