First time here? Check out the FAQ!
1

Remote debugging on Heroku

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?

Chris Curvey's avatar
246
Chris Curvey
asked 2021-09-30 07:49:00 -0600
Wingware Support's avatar
4.2k
Wingware Support
updated 2021-10-01 12:01:43 -0600
edit flag offensive 0 remove flag 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's avatar Wingware Support (2021-09-30 09:22:44 -0600) 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's avatar Chris Curvey (2021-09-30 10:50:40 -0600) 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's avatar Wingware Support (2021-09-30 11:31:53 -0600) 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's avatar Chris Curvey (2021-09-30 11:44:50 -0600) 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's avatar Wingware Support (2021-09-30 13:08:26 -0600) edit
add a comment see more comments

1 Answer

0

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

Wingware Support's avatar
4.2k
Wingware Support
answered 2021-10-01 14:10:20 -0600
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer