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 Error Xdebug: [Step Debug] Could not connect to debugging client #11

Open
stefnats opened this issue Sep 16, 2021 · 7 comments

Comments

@stefnats
Copy link

Hello,

i'm using this container with the following config (devcontainer.json):

// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.0/containers/php
{
	"name": "PHP",
	"build": {
		"dockerfile": "Dockerfile",
		"args": { 
			// Update VARIANT to pick a PHP version: 8, 8.0, 7, 7.4, 7.3
			"VARIANT": "8",
			"NODE_VERSION": "lts/*"
		}
	},
	
	// Set *default* container specific settings.json values on container create.
	"settings": { 
		"php.validate.executablePath": "/usr/local/bin/php"
	},

	// Add the IDs of extensions you want installed when the container is created.
	"extensions": [
		"felixfbecker.php-debug",
		"bmewburn.vscode-intelephense-client",
		"mrmlnc.vscode-apache",
		"calebporzio.better-phpunit"
	],

	// Use 'forwardPorts' to make a list of ports inside the container available locally.
	// "forwardPorts": [8080],

	// Use 'portsAttributes' to set default properties for specific forwarded ports. More info: https://code.visualstudio.com/docs/remote/devcontainerjson-reference.
	"portsAttributes": {
		"8000": {
			"label": "Hello Remote World",
			"onAutoForward": "notify"
		}
	},

	// Use 'otherPortsAttributes' to configure any ports that aren't configured using 'portsAttributes'.
	// "otherPortsAttributes": {
	// 		"onAutoForward": "silent"
	// },

	// Use 'postCreateCommand' to run commands after the container is created.
	// "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html"

	// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
	"remoteUser": "vscode"
}

When i run any php process i receive this error

Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9000 (through xdebug.client_host/xdebug.client_port) :-(

Dockerfile is still as is: https://github.com/microsoft/vscode-remote-try-php/blob/67e233b925a64f90a46092879ed82b9e6d89f19e/.devcontainer/Dockerfile

Am i doing something wrong? Thanks in advance!

@ikhvjs
Copy link

ikhvjs commented Sep 30, 2021

Same issue with the default preconfig image of PHP

devcontainer.json

// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.194.3/containers/php
{
	"name": "PHP",
	"build": {
		"dockerfile": "Dockerfile",
	},
	"settings": { 
		"php.validate.executablePath": "/usr/local/bin/php"
	},
	"extensions": [
		"felixfbecker.php-debug",
		"bmewburn.vscode-intelephense-client",
		"mrmlnc.vscode-apache"
	],
	"forwardPorts": [8080],
	"remoteUser": "vscode"
}

Dockerfile

ARG VARIANT="7.4"
FROM mcr.microsoft.com/vscode/devcontainers/php:0-${VARIANT}

@mabasic
Copy link

mabasic commented Sep 30, 2021

This is normal when not debugging the application. By default xdebug listens for a "debugging" connection. If you are not debugging, then it displays the warning that you are seeing. When you try running your application with F5 (debugging mode) then you will not see that message.

@ikhvjs
Copy link

ikhvjs commented Sep 30, 2021

@mabasic , I try to F5 to debug. I can see the server is running in remote container localhost:9003 and I try to browse the page in local localhost:9003, but there is no response.

I also try in terminal with telnet localhost 9003 in local and there is no connection as well.

@mabasic
Copy link

mabasic commented Sep 30, 2021

When you start debugging in vs code, you should open the browser to the port on which your application is running, not the port of the debugger.

Set a breakpoint in vscode, make a request to your application so that the breakpoint is triggered and you will see that the application execution is paused and that you can see the current variables in vsvode.

@ikhvjs
Copy link

ikhvjs commented Sep 30, 2021

@mabasic , I try your suggestion. when you run F5 and enter the debugging mode, you can see your runing process is on the port 9003. I try to browse both port 8080 and 9003, but I cannot reach both of them.
You can see the ports from the ports tab of VSCODE terminal panel below:
image

@mabasic
Copy link

mabasic commented Sep 30, 2021

See the readme for debugging instructions. I think that you need to start the server first.

@ikhvjs
Copy link

ikhvjs commented Sep 30, 2021

@mabasic , Thanks. I manage to solve the issue. It turns out that I use the default launch.json from VScode and it doesn' work. I try to copy the launch.json of the repo and it works fine.

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

3 participants