Xdebug: [Step Debug] 连接调试客户端超时,等待:200 ms.试过:本地主机:9003 [英] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003

查看:85
本文介绍了Xdebug: [Step Debug] 连接调试客户端超时,等待:200 ms.试过:本地主机:9003的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 php.ini 配置:

My php.ini configuration:

[XDebug]
zend_extension = "C:xamppphpextphp_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 配置:

My launch.json configuration:

{
    // 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 中收到此错误:

but i am still getting this error in 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 无法正常工作并且不在断点处停止.

First I used the port 9000 but it didn't work, then I tried changing the port in php.ini and launch.json to 9003 same as the port in error log but still nothing is happening and XDebug is not working and not stopping on breakpoints.

推荐答案

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

I also encouneter with such an error after updting my Xdebug library to 3+ version.

我发现新设置 xdebug.start_with_request = yes 将 Xdebug 配置为在每个请求上建立连接,这对于开发环境来说也是不必要的.

What i found out is that new setting xdebug.start_with_request = yes configures Xdebug to establish a connection on every request, which is unnecessary even for development environment.

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

Meanwhile the official doc offers to use xdebug.start_with_request = trigger in order to connect Xdebug only if the need for it was explicitly indicated. In this case i can start step debugging process with passing an extra key via GET parameters, for example http://localhost/?XDEBUG_TRIGGER=1, but this is inconvenient for me, all I want is press F5 within my VSCode to start debugging as I always did.

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

So my solution is the following. I left start_with_request = yes and turned off most of Xdebug notifications by passing xdebug.log_level = 0. Then i override log_level within launch.json file to enable all warnings but only within debugging 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

launch.json:

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

这篇关于Xdebug: [Step Debug] 连接调试客户端超时,等待:200 ms.试过:本地主机:9003的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆