Saturday, March 2, 2019

Debugging remote nodejs applications

If you want to debug a nodejs application that runs on a remote Linux server from a local Windows machine with Chrome, do the following:

Go to the Linux machine and make sure that the debugging port is opened in the firewall
ufw status
ufw allow 9229
start the nodejs application in debug mode
node --inspect app.js

Alternatives:
use node --inspect-brk app.js to start it with a breakpoint at the beginning
use node --inspect=linuxserver.com:9229 app.js to make a debugger listen on a public port. Don't do this.

Open Chrome and go to chrome:inspect
Your application doesn't appear because Chrome is only looking on local ports
Since node --inspect app.js makes the remote debugger listen on 127.0.0.1 it doesn't make sense to add the Linux server to your configuration in chrome:inspect. Instead configure a tunnel: open cmd and type
ssh -nNT -L 9229:127.0.0.1:9229 user@linuxserver.com
if you have an rsa key to logon to your remote server
ssh -nNT -L 9229:127.0.0.1:9229 user@linuxserver.com -i keyfile

Port 9229 of your local Windows machine is now forwared to the remote Linux server. In chrome:inspect under Remote Target #LOCALHOST a link apears that you can use to debug your application running on the remote Linux server in Chrome on your local machine.

(What has that to do with SAP? Cloud is comming for ABAPers)

No comments:

Post a Comment

Working with the session Id // ID für den Modus

Sometimes it can be helpful to know the id of the current session     CALL FUNCTION 'TH_GET_CONTEXT_ID'       IMPORTING         cont...