简体   繁体   English

PHP Xdebug超时连接到客户端(Docker,VSCode,Ubuntu)

[英]PHP Xdebug Time-out connecting to client (Docker, VSCode, Ubuntu)

I'm trying to troubleshoot a Docker/PHP-Xdebug/VSCode environment on Ubuntu that has been working very well for the last few months. 我正在尝试对在过去几个月中运行良好的Ubuntu上的Docker / PHP-Xdebug / VSCode环境进行故障排除。 And now xdebug have trouble connecting to the client. 现在,xdebug无法连接到客户端。

After entering the Docker with docker exec --tty --interactive bw bash 使用docker exec --tty --interactive bw bash进入Docker之后

php -v

returns 退货

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

while php -m -c lists Xdebug in the [Zend Modules] section. php -m -c在[Zend Modules]部分列出Xdebug。

Here is the .ini part 这是.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

Eveything in there is reflected accordingly in phpinfo() output. 那里的一切反映在phpinfo()输出中。

docker-compose.yml 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 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
        }    ]
}

This is the tail of the xdebug.log 这是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

I strongly suspect my lack of Docker knowledge is the problem to make this work again. 我强烈怀疑我缺乏Docker知识是重新进行这项工作的问题。

Any help would be appreciated. 任何帮助,将不胜感激。

Problem was with the firewall of the host. 问题出在主机的防火墙上。 Can't really tell how/why the rule disappeared. 无法真正说出规则为何/为什么消失。
I was probing the port with telnet the wrong way around and that led me thinking the firewall was letting traffic through. 我在用telnet探测端口时使用了错误的方式,这使我想到防火墙正在允许流量通过。 ufw allow from any to any port 9000 proto tcp on the host did in fact re-establish everything. 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM