简体   繁体   中英

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

My php.ini configuration:

[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"

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
        }
        

    ]
}

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

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.

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

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.

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.

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",
            }
        }
    ]
}

I encountered the same issue with PHP8. In my case, it was just the XDebug version suggested by their own wizard. I use this version and it works just fine. php_xdebug-3.0.0-8.0-vs16-x86_64

launch.json:

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

change pathmappings according to your requirements and the most important is hostname. after i added that, it worked

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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