Ask Your Question
1

Remote debugging on Heroku

asked 2021-09-30 07:49:00 -0500

Chris Curvey gravatar image

updated 2021-10-01 12:01:43 -0500

For today's adventure, I'm going to try setting up remote debugging on a Heroku dyno. If anyone has gotten this to work (or determined that it will not work), I'd love to hear about it.

So here's what I've found so far.

I found instructions on SSH tunneling to my dyno at https://devcenter.heroku.com/articles.... Heroku does not permit a straight "ssh" command, but it does have a command to set up port forwarding from the local host to the dyno. (heroku ps:forward). It does not look like that command also sets up the reverse tunnel :(

So I think the set of steps that I will need is:

  1. Set a value for kSecurityToken in my wingdbstub.py
  2. Add wingdbstub.py to my git repository, so that it gets pushed with the rest of my deployment
  3. Set up the appropriate DNS & Firewall rules so that the dyno can open a connection to my development host

Do I need to add some base level of Wing code (the "remote" stuff) into my git repo so that it gets installed on the dyno?

edit retag flag offensive close merge delete

Comments

Remote debugging is hard without a reverse tunnel, but it is possible to establish the connection from the IDE using the Debug > Processes > Attach to Process dialog. You'd set up a forward tunnel and then connect to the local end of the tunnel.

Setting up a reverse connection without the SSH tunnel, particularly over the open internet, is _not_ something that we recommend. Wing relies on the SSH tunnel for encryption and authentication.

Wingware Support gravatar image Wingware Support  ( 2021-09-30 09:22:44 -0500 )edit

okay, so how would I do that? Is it

  1. add "import wingdbstub" somewhere in my server code where it gets processed on startup
  2. Once the server is started, use the "Attach to Process" dialog,
  3. Set the breakpoint where I need it
  4. Poke the server in such a way that it will execute to the breakpoint?
Chris Curvey gravatar image Chris Curvey  ( 2021-09-30 10:50:40 -0500 )edit

That should be pretty much it. You can see if the debugger is connected to the IDE using (not sys._wing_debugger.ChannelClosed()). The port to attach to is defined by kAttachPort in wingdbstub.py

Wingware Support gravatar image Wingware Support  ( 2021-09-30 11:31:53 -0500 )edit

hmm...I'm trying to make sure I can make this work locally before I add the remote complication.

  1. Put "import wingdbstub" at the bottom of my project-level urls.py
  2. Start the Django server in a terminal. Wing switches to debug mode (big red square "stop" button is activated)
  3. Stop wing
  4. Start wing
  5. Debug -> Processes -> Attach to Process. That says "127.0.0.1:50015". (Which is the stock configuration, I think)
  6. get message about "The debug process never connected back to Wing".
Chris Curvey gravatar image Chris Curvey  ( 2021-09-30 11:44:50 -0500 )edit

My mistake -- the attach protocol doesn't work like I thought. It still requires a way for the debugger to connect back to the IDE.. We'll see if we can change this in a future release, but for now it won't work with Heroku.

Wingware Support gravatar image Wingware Support  ( 2021-09-30 13:08:26 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-10-01 14:10:20 -0500

Wing currently does not support remote debugging on a Heroku dyno because of the inability to create a reverse SSH tunnel.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2021-09-30 07:49:00 -0500

Seen: 43 times

Last updated: Oct 11