VS Code Remote Debugging does not work for me

Dear Community,

I am running OH 2.x on my local windows box. I got the common “Cannot connect to Debuggee” error, aka “Failed to attach to remote debuggee VM … Connection refused.” in VS Code. Sometimes the debug-task starts without an error message, but I am not able to hit the breakpoints, that VS Code is stopping at them and showing me the common views like variables and jump-options.

My launch.json looks like that:

“version”: “0.2.0”,
“configurations”: [
“type”: “java”,
“name”: “Debug (Attach) - openHAB”,
“request”: “attach”,
“hostName”: “localhost”,
“port”: 5005,
“preLaunchTask”: “Build”

Anyway, is there a possibility to use an external debugger or is there some progress on using IntelliJ for OH development, i.e. an official guide in the OH docs?

I am really happy, that I can build and deploy my addons now and I am eclipse independant. Writing some OH-related Java code works with VS Code as well, but now I need to make sure, that I am able to debug efficiently - writing log-statements is a little bit “Seventies”, isn’t it?

Thanks in advance for your short reply!

Best regards,

1 Like

Did you start OH with the debug switch (start.bat debug)? Won’t open up the debug port without that…

Dear Tim,

thanks for your hint. I guess the correct options will be called, as I conclude after viewing the VS Code tasks file:

“tasks”: [
“label”: “Start openHAB (Debug)”,
“type”: “shell”,
“isBackground”: true,
“command”: “$env:openhab_home/start.sh”,
“windows”: {
“command”: “& $env:openhab_home/start.bat debug”
“presentation”: {
“reveal”: “always”,
“panel”: “new”
“problemMatcher”: []

Ahh - the command on linux/osx is incorrect and needs the “debug” after start.sh. I’ll create a PR to fix that…

Thanks Tim,

Anyway - my system runs on a windows box, so that couldn’t be the problem.

Best regards,

When you start OH with the debug option - the console should show a line like:
Listening for transport dt_socket at address: xxxx (where xxxx is the port - likely 5005)

Do you see that and is it 5005? I’d check to see if something else on the system is listening on that port as well…

1 Like