使用dbgpProxy时Xdebug无法连接本地计算机的问题排查
Xdebug + dbgpProxy 调试连接失败问题排查
相关配置文件
launch.json 配置
{ "name": "Remote listen for Xdebug", "type": "php", "request": "launch", "port": 26357, "xdebugSettings": { "max_children": 128, "max_data": -1, "max_depth": 3 }, "pathMappings": { "/share/ZFS2_DATA/Web/dolibarr-1": "${workspaceRoot}", "/share/ZFS2_DATA/Web/dolibarr-2": "${workspaceRoot}", "/share/ZFS2_DATA/Web/dolibarr-3": "${workspaceRoot}", "/share/ZFS2_DATA/Web/dolibarr-4": "${workspaceRoot}", }, "log": true, "proxy": { "enable": true, "host": "192.168.1.88", "port": 26356, "key": "VSCODE", "allowMultipleSessions": false } },
99-xdebug.ini 配置
[xDebug] zend_extension = xdebug xdebug.mode = debug,develop xdebug.remote_handler = "dbgp" xdebug.remote_cookie_expire_time = 36000 xdebug.start_with_request=trigger ;xdebug.discover_client_host=true ;xdebug.client_host = 192.168.1.57 xdebug.client_host = 127.0.0.1 xdebug.client_port = 26357 xdebug.show_exception_trace=false xdebug.log = /tmp/xdebug.log xdebug.log_level=10 xdebug.trigger_value=VSCODE xdebug.idekey=VSCODE
dbgpProxy 启动命令及输出
启动命令:
./dbgpProxy -s 0.0.0.0:26357 -i 0.0.0.0:26356
启动输出:
[david@localhost ~]$ ./dbgpProxy -s 0.0.0.0:26357 -i 0.0.0.0:26356 Xdebug DBGp proxy (0.6.1) Copyright %s by Derick Rethans 2024 2024-11-11 07:20:38.038 [warn] [SSL] The 'certs/fullchain.pem' file could not be found, not enabling SSL listeners 2024-11-11 07:20:38.039 [info] [dbgpProxy] Proxy started 2024-11-11 07:20:38.039 [info] [server] Started server server on 0.0.0.0:26357 2024-11-11 07:20:38.039 [info] [server] Started client server on 0.0.0.0:26356 2024-11-11 07:20:41.436 [info] [server] Start new client connection from 192.168.1.57:11892 2024-11-11 07:20:41.953 [info] [proxyinit] [VSCODE] Added connection for IDE Key 'VSCODE': 192.168.1.57:26357 2024-11-11 07:20:41.953 [info] [server] Closing client connection from 192.168.1.57:11892
VSCode 输出信息
Registering VSCODE on port 26357 with proxy @ 192.168.1.88:26356 Registration successful
Xdebug 日志内容
[30035] [Step Debug] <- detach -i 1 -- "dbgpProxy has no IDE connected to it" [30035] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="detach" transaction_id="1" status="stopping" reason="ok"></response> [30035] [Step Debug] WARN: Debug client detached: "dbgpProxy has no IDE connected to it". [30035] Log closed at 2024-11-11 07:34:21.343605 [942] Log opened at 2024-11-11 07:34:25.171655 [942] [Config] DEBUG: Checking if trigger 'XDEBUG_TRIGGER' is enabled for mode 'debug' [942] [Config] INFO: Trigger value for 'XDEBUG_TRIGGER' not found, falling back to 'XDEBUG_SESSION' [942] [Config] DEBUG: The trigger value 'VSCODE' matched the shared secret 'VSCODE' for mode 'debug' [942] [Step Debug] INFO: Connecting to configured address/port: 127.0.0.1:26357. [942] [Step Debug] INFO: Connected to debugging client: 127.0.0.1:26357 (through xdebug.client_host/xdebug.client_port). :-) [942] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///share/ZFS2_DATA/Web/dolibarr-1/htdocs/custom/evterceros/billing/api/firmarFacturas.php" language="PHP" xdebug:language_version="7.4.30" protocol_version="1.0" appid="942" idekey="VSCODE"><engine version="3.1.6"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2022 by Derick Rethans]]></copyright></init> [942] [Step Debug] <- detach -i 1 -- "dbgpProxy has no IDE connected to it" [942] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="detach" transaction_id="1" status="stopping" reason="ok"></response> [942] [Step Debug] WARN: Debug client detached: "dbgpProxy has no IDE connected to it". [942] Log closed at 2024-11-11 07:34:25.223544
dbgpProxy 日志内容
2024-11-11 07:34:00.364 [info] [server] Start new client connection from 192.168.1.57:12102 2024-11-11 07:34:00.869 [info] [proxyinit] [VSCODE] Added connection for IDE Key 'VSCODE': 192.168.1.57:26357 2024-11-11 07:34:00.869 [info] [server] Closing client connection from 192.168.1.57:12102 2024-11-11 07:34:21.342 [err ] [proxy-client] [VSCODE] IDE not connected: dial tcp 192.168.1.57:26357: connect: connection timed out 2024-11-11 07:34:21.342 [warn] [proxy-client] [VSCODE] Removed connection information for 'VSCODE': dial tcp 192.168.1.57:26357: connect: connection timed out 2024-11-11 07:34:21.343 [warn] [server] Handler response error: Error reading response: Error reading length: EOF 2024-11-11 07:34:21.343 [info] [server] Closing server connection from 127.0.0.1:48254 2024-11-11 07:34:25.172 [info] [server] Start new server connection from 127.0.0.1:48350 2024-11-11 07:34:25.172 [info] [proxy-client] [VSCODE] Could not find IDE connection for IDE Key 'VSCODE' 2024-11-11 07:34:25.172 [warn] [server] Handler response error: Error reading response: Error reading length: EOF 2024-11-11 07:34:25.172 [info] [server] Closing server connection from 127.0.0.1:48350
疑问
- 当前问题是端口使用错误,还是防火墙限制?已确认iptables和Windows防火墙无相关限制,怀疑是物理防火墙导致。
- 捕获到的数据包(目标IP为192.168.1.57,端口26357)是否是代理服务器尝试连接我的计算机?
内容的提问来源于stack exchange,提问作者Daviid
相关产品推荐
相关产品推荐

