簡體   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