How to remote debug a node.js app on heroku?
Asked Answered
B

4

6

I'm currently building a node.js chatbot which I then deploy on heroku. The app uses webhooks which must be at a public URL that the servers can reach. Therefore, running the server locally on my machine will not work. Is there a way I can remote debug my app? Any tips?

Blockbuster answered 29/8, 2016 at 20:40 Comment(0)
C
2

I would consider using a tool to connect public URLs to an instance of your app running locally.

Option 1: ngrok

An easy one would be ngrok

Option 2: ssh reverse tunneling

If you have access to any Internet-facing server with ssh and admin rights to enable the GatewayPorts yes sshd configuration, you can do it with ssh remote tunneling. For example:

ssh -n -R 8080:localhost:3000 myserver.example.com

Will allow webhooks sent to http://myserver.example.com:8080 to tunnel to your local app listening on port 3000.

More details on ssh tunneling can be found here

Changeup answered 29/8, 2016 at 23:6 Comment(0)
L
2

You can indeed debug webhooks on your local computer using a free proxy service like ngrok.

If you want to debug it on Heroku, you can view your real-time logs using heroku logs --tail or use an addon service that stores logs.

Limes answered 29/8, 2016 at 23:4 Comment(0)
C
2

I would consider using a tool to connect public URLs to an instance of your app running locally.

Option 1: ngrok

An easy one would be ngrok

Option 2: ssh reverse tunneling

If you have access to any Internet-facing server with ssh and admin rights to enable the GatewayPorts yes sshd configuration, you can do it with ssh remote tunneling. For example:

ssh -n -R 8080:localhost:3000 myserver.example.com

Will allow webhooks sent to http://myserver.example.com:8080 to tunnel to your local app listening on port 3000.

More details on ssh tunneling can be found here

Changeup answered 29/8, 2016 at 23:6 Comment(0)
T
1

Found an easier solution.

Install the LogDNA add-on, and then run the app and see the error stack trace.

then when you see the error and which line it happened on, it is pretty easy to find the problem.

Thready answered 18/6, 2017 at 3:14 Comment(0)
G
-1

Use Papertrail addon or can also use the logging options mentioned here https://devcenter.heroku.com/articles/logging.

Geny answered 14/2, 2021 at 11:56 Comment(1)
A link to a solution is welcome, but please ensure your answer is useful without it: add context around the link so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. Answers that are little more than a link may be deleted.Clydesdale

© 2022 - 2024 — McMap. All rights reserved.