[英]PHP Xdebug Time-out connecting to client (Docker, VSCode, Ubuntu)
我正在尝试对在过去几个月中运行良好的Ubuntu上的Docker / PHP-Xdebug / VSCode环境进行故障排除。 现在,xdebug无法连接到客户端。
使用docker exec --tty --interactive bw bash
进入Docker之后
php -v
退货
PHP 7.2.14 (cli) (built: Feb 6 2019 05:10:24) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans
而php -m -c
在[Zend Modules]部分列出Xdebug。
这是.ini部分
[xdebug]
xdebug.default_enable = 1
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.idekey = VSCODE
xdebug.remote_handler = "dbgp"
xdebug.remote_port = 9000
xdebug.remote_log=/var/log/apache2/xdebug.log
xdebug.remote_timeout = 500
那里的一切反映在phpinfo()
输出中。
docker-compose.yml
version: "3.1"
services:
webserver:
build: docker/apache
container_name: bw
volumes:
- .:/var/www/html
ports:
- "8000:80"
expose:
- "9000"
restart: always
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"log":true,
"pathMappings": {
"/var/www/html": "${workspaceRoot}/",
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
} ]
}
这是xdebug.log的结尾
[156] Log opened at 2019-08-05 19:39:58
[156] I: Checking remote connect back address.
[156] I: Checking header 'HTTP_X_FORWARDED_FOR'.
[156] I: Checking header 'REMOTE_ADDR'.
[156] I: Remote address found, connecting to 172.18.0.1:9000.
[156] E: Time-out connecting to client (Waited: 500 ms). :-(
[156] Log closed at 2019-08-05 19:39:59
我强烈怀疑我缺乏Docker知识是重新进行这项工作的问题。
任何帮助,将不胜感激。
问题出在主机的防火墙上。 无法真正说出规则为何/为什么消失。
我在用telnet探测端口时使用了错误的方式,这使我想到防火墙正在允许流量通过。 ufw allow from any to any port 9000 proto tcp
主机上的ufw allow from any to any port 9000 proto tcp
实际上重新建立了所有内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.