I'm looking for a little help in debugging my app using Visual Studio Code, where my app is held in a virtual machine hosted by Oracle Virtual Box.
The VM has been provisioned with a typical setup of node, express, node-inspector etc. and I am able to debug my app using node-inspector (i.e. the port for node-inspector has been forwarded within the vm and if I set my app running with "node --debug-brk app.js" it listens on port 5858 and I can navigate to localhost:8080/debug?port=5858 to start debugging).
However in VSC if I use the "attach" option in debug I cannot get to a breakpoint at all.
Is there something special that I am missing here or are there any log files I can look at - I'm on OSX Yosemite and the VM OS is running in virtual box is a headless OpenSuse, provisioned with vagrant?
NB: I have tried telnetting to the VM on port 5858 and I get a different response from within the VM to the local machine itself, as indicated below:
Inside the VM:
telnet 127.0.0.1 5858
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Type: connect
V8-Version: 3.14.5.9
Protocol-Version: 1
Embedding-Host: node v0.10.32 Content-Length: 0
Outside the VM:
telnet 127.0.0.1 5858
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
Any help would be much appreciated?
Yes I'm running VSCode outside the VM - The VM is headless.
The ports are already configured to be forwarded inside the vagrant provisioning script. However a colleague has informed me that there might be a company policy that is being forced upon us relating to our network adapters - preventing/causing my connection issue.
However I've tried a different approach. I've tunnelled a connection via ssh for all the traffic on port 5858:
ssh -i myprivatekey -L 5858:localhost:5858 tempuserlocalhost -p 2222
Now when I start debugging the app (i.e. node --debug app.js) and use the attach option the debugger clearly attaches. It doesn't hit my breakpoint in app.js though, when it should do.
In actual fact if I pause the debugger I get a list of the local variables and a call stack but the following error is shown:
Error opening 'app.js' (File not found)
Note: app.js and the other code files are not held on the VM, they are held on my local machine with samba shares configured accordingly. Perhaps this is causing the confusion?