Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging with Remote SSH #360

Closed
andrews05 opened this issue Jun 9, 2019 · 11 comments
Closed

Debugging with Remote SSH #360

andrews05 opened this issue Jun 9, 2019 · 11 comments

Comments

@andrews05
Copy link

andrews05 commented Jun 9, 2019

I've been successfully using PHP Debug with a remote host in a normal project. However I've just setup the new Remote - SSH extension and am trying to get PHP Debug to work with that. Is this possible? What do I need to do?

@andrews05
Copy link
Author

Okay, so I got this to work by configuring xdebug with xdebug.remote_host=127.0.0.1 and disabling xdebug.remote_connect_back.

@zobo
Copy link
Contributor

zobo commented Jun 25, 2019

Yes, the dbgp code runs on the remote server, while http requests come from your browser... Would be a nice use-case for dbgp proxy...

@kczx3
Copy link

kczx3 commented Jan 29, 2020

I cannot get this to work either. Oddly enough, if I use an undefined constant then the debugger works and pauses on the exception. However, adding a breakpoint has no effect whatsoever. The code will not halt on the breakpoint. Any ideas?

@zobo
Copy link
Contributor

zobo commented Jan 29, 2020

That would point to invalid path mapping. Check if you have anything under pathMappings in your config. Or something else wrong with paths. Do you use docker or similar? You can also set stopOnEntry and log in your config, to help debug this.

@kczx3
Copy link

kczx3 commented Jan 29, 2020

I have the following folder open in my workspace "~/public_html/mlinks" and that is the document root for the web application. My pathMapping thus contains "~/public_html/mlinks/": "${workspaceFolder}". I did try expanding out the tilde to the actual path but that didn't change. I feel that my understanding of pathMappings might be inaccurate.

@zobo
Copy link
Contributor

zobo commented Jan 29, 2020

If you are using VSCode Remote SSH that means that the debugger client is running on the same box as the web server. You should not need the pathMapping, try to remove it.

@dalarworld
Copy link

Okay, so I got this to work by configuring xdebug with xdebug.remote_host=127.0.0.1 and disabling xdebug.remote_connect_back.

Hi,

I have tried this configuration & it works. Problem is now it doesn't work with local configuration.

Do we have some setting / configuration which will work in all scnerio?

I tried several scenario where used SSH-FS but it needs files in local PC to debug. Help will be highly appreciated.
Following works for remote debugging:

zend_extension=/usr/lib/php/20190902/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_port = 9001
xdebug.remote_host = 127.0.0.1
xdebug.max_nesting_level = 512
xdebug.remote_handler=dbgp
xdebug.remote_autostart=1
xdebug.remote_log = /tmp/rxdebug.log

Following Works for Debugging when I have files in Local Folder & Uploading them via SCP:

zend_extension=/usr/lib/php/20190902/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9001
xdebug.max_nesting_level = 512
xdebug.remote_handler=dbgp
xdebug.remote_autostart=1
xdebug.remote_log = /tmp/rxdebug.log

@zobo
Copy link
Contributor

zobo commented Mar 2, 2020

Hi. Mixing these two scenarios is problematic. In theory there are two ways to do this:

  1. use a dbgpproxy, where the proxy runs on the server, next to php, and php uses xdebug.remote_host=127.0.0.1 but this plugin lacks proxy support (there's an open PR, but doesn't go anywhere)
  2. Leave the xdebug.remote_connect_back=true and use the SSH tunnel feature of VSCode remote to actually connect to PHP through the tunnel, so that PHP (webserver) will see connections comming from 127.0.0.1. This would however require manipulating your workstation PCs /etc/hosts (or some other way) to trick your browser to connect to your VSCode clients endpoint of the SSH tunnel.

@dalarworld
Copy link

My question is if we enable to provide SCP path to pathMappings settings in your launch.json it can solve this scenario.
"pathMappings": {
"/var/www/html": "${workspaceRoot}/www"
}

==> Here if we could point SCP Mounted file system path

@kaktuspalme
Copy link

kaktuspalme commented Jul 10, 2020

I "solved" it adding this to the apache configuration:

     RewriteEngine On
     RewriteCond %{QUERY_STRING} ^(?:.*&)?localdebug=true.*$
     RewriteRule ^ - [E=DEBUG_HOST:localhost]

Then in the xdebug.ini I set the following:
xdebug.remote_addr_header="DEBUG_HOST"

Then when I add to the url ?localdebug=true it will use localhost.
But I'm still searching for a better solution than this.

Edit: Thanks for the tip for using port forwarding. When debug session is started I just forward Port 9000 in the Remote Explorer plugin and everything is working.

@zobo
Copy link
Contributor

zobo commented May 20, 2022

Support for dbgp proxy was implemented. Open new is this is still an issue you are facing.

@zobo zobo closed this as completed May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants