繁体   English   中英

Xdebug: [Step Debug] 连接调试客户端超时,等待:200 ms。 试过:本地主机:9003

[英]Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003

我的 php.ini 配置:

[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"   
xdebug.mode = debug 
xdebug.remote_autostart = on
xdebug.profiler_enable = on
xdebug.profiler_enable_trigger = on
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="c:/xampp/tmp"
xdebug.show_local_vars=0
xdebug.remote_host = 127.0.0.1
xdebug.remote_enable = 1
xdebug.remote_port = 9003
xdebug.remote_handler = dbgp
xdebug.remote_mode = req
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
xdebug.remote_autostart=1
xdebug.idekey=PHPSTORM
xdebug.remote_log="c:/xampp/tmp/xdebug.log"

我的launch.json配置:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9003
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9003
        }
        

    ]
}

但我仍然在error.log中收到此错误:

[php:notice] [pid 9388:tid 1840] [client ::1:63322] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost/online-store/admin/types/insert-types.php

首先我使用端口 9000 但它不起作用,然后我尝试更改 php.ini 中的端口并将 launch.json 更改为 9003 与错误日志中的端口相同,但仍然没有发生任何事情并且 XDebug 没有工作并且没有停止断点。

在将我的 Xdebug 库更新到 3+ 版本后,我也遇到了这样的错误。

我发现新设置xdebug.start_with_request = yes将 Xdebug 配置为在每个请求上建立连接,即使对于开发环境也是如此。

同时,官方文档提供使用xdebug.start_with_request = trigger以便仅在明确指出需要时连接 Xdebug。 在这种情况下,我可以通过 GET 参数传递一个额外的密钥来开始逐步调试过程,例如http://localhost/?XDEBUG_TRIGGER=1 ,但这对我来说很不方便,我只想在我的 VSCode 中按 F5 开始调试就像我一直做的那样。

所以我的解决方案如下。 我离开start_with_request = yes并通过传递xdebug.log_level = 0关闭了大多数 Xdebug 通知。 然后我在launch.json文件中覆盖log_level以启用所有警告,但仅在调试session中。

php.ini

[XDebug]
zend_extension = php_xdebug-3.0.4-7.4-vc15-x86_64.dll
xdebug.mode = debug,develop
xdebug.discover_client_host = yes
xdebug.log_level = 0
xdebug.log = "%sprogdir%/userdata/temp/xdebug/log.txt"
xdebug.start_with_request = yes
xdebug.idekey = VSCODE

发射.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "env": {
                "XDEBUG_CONFIG": "log_level=7",
            }
        }
    ]
}

我在 PHP8 中遇到了同样的问题。 就我而言,这只是他们自己的向导建议的 XDebug 版本。 我使用这个版本,它工作得很好。 php_xdebug-3.0.0-8.0-vs16-x86_64

发射.json:

       {
            "name": "Listen for Xdebug",  
            "type": "php",  
            "request": "launch",  
            "port": 9003,  
            "hostname": "localhost",  
            "pathMappings": {
                "/var/www/html": "${workspaceRoot}/www/"
            },
        },

根据您的要求更改路径映射,最重要的是主机名。 在我添加之后,它起作用了

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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