【问题标题】:Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (fallback through xdebug.client_host/xdebug.client_port) :-(Xdebug:[Step Debug] 无法连接到调试客户端。尝试过:localhost:9003(通过 xdebug.client_host/xdebug.client_port 回退):-(
【发布时间】:2021-03-17 15:29:33
【问题描述】:

这个消息对于 xdebug ang php 的解决方法是什么?

Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (fallback through xdebug.client_host/xdebug.client_port) :-(

当我在安装有UBUNTU 20.01WSL2 上运行composer update 时出现此消息。

我当前的php版本是php8xdebug3

更新:

这是 x-debug 部分

xdebug

__   __   _      _
\ \ / /  | |    | |
 \ V / __| | ___| |__  _   _  __ _
  > < / _` |/ _ \ '_ \| | | |/ _` |
 / . \ (_| |  __/ |_) | |_| | (_| |
/_/ \_\__,_|\___|_.__/ \__,_|\__, |
                              __/ |
                             |___/

Version => 3.0.1
Support Xdebug on Patreon, GitHub, or as a business: https://xdebug.org/support

Feature => Enabled/Disabled
Development Aids => ✘ disabled
Coverage => ✘ disabled
GC Stats => ✘ disabled
Profiler => ✘ disabled
Step Debugger => ✔ enabled
Tracing => ✘ disabled

Debugger => enabled
IDE Key =>

Directive => Local Value => Master Value
xdebug.auto_trace => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.auto_trace" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.auto_trace"
xdebug.cli_color => 0 => 0
xdebug.client_discovery_header => no value => no value
xdebug.client_host => localhost => localhost
xdebug.client_port => 9003 => 9003
xdebug.cloud_id => no value => no value
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.collect_includes" => This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.collect_includes"
xdebug.collect_params => 0 => 0
xdebug.collect_return => Off => Off
xdebug.collect_vars => This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.collect_vars" => This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.collect_vars"
xdebug.connect_timeout_ms => 200 => 200
xdebug.coverage_enable => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.coverage_enable" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.coverage_enable"
xdebug.default_enable => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.default_enable" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.default_enable"
xdebug.discover_client_host => On => On
xdebug.dump.COOKIE => no value => no value
xdebug.dump.ENV => no value => no value
xdebug.dump.FILES => no value => no value
xdebug.dump.GET => no value => no value
xdebug.dump.POST => no value => no value
xdebug.dump.REQUEST => no value => no value
xdebug.dump.SERVER => no value => no value
xdebug.dump.SESSION => no value => no value
xdebug.dump_globals => On => On
xdebug.dump_once => On => On
xdebug.dump_undefined => Off => Off
xdebug.file_link_format => no value => no value
xdebug.filename_format => no value => no value
xdebug.force_display_errors => Off => Off
xdebug.force_error_reporting => 0 => 0
xdebug.gc_stats_enable => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.gc_stats_enable" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.gc_stats_enable"
xdebug.gc_stats_output_dir => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.gc_stats_output_dir" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.gc_stats_output_dir"
xdebug.gc_stats_output_name => gcstats.%p => gcstats.%p
xdebug.halt_level => 0 => 0
xdebug.idekey => no value => no value
xdebug.log => no value => no value
xdebug.log_level => 7 => 7
xdebug.max_nesting_level => 256 => 256
xdebug.max_stack_frames => -1 => -1
xdebug.mode => debug => debug
xdebug.output_dir => /mnt/c/www/traces => /mnt/c/www/traces
xdebug.overload_var_dump => This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.overload_var_dump" => This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.overload_var_dump"
xdebug.profiler_append => Off => Off
xdebug.profiler_enable => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_enable" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_enable"
xdebug.profiler_enable_trigger => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_enable_trigger" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_enable_trigger"
xdebug.profiler_enable_trigger_value => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_enable_trigger_value" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_enable_trigger_value"
xdebug.profiler_output_dir => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_output_dir" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_output_dir"
xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p
xdebug.remote_autostart => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_autostart" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_autostart"
xdebug.remote_connect_back => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_connect_back" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_connect_back"
xdebug.remote_enable => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_enable" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_enable"
xdebug.remote_host => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_host" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_host"
xdebug.remote_log => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_log" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_log"
xdebug.remote_log_level => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_log_level" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_log_level"
xdebug.remote_mode => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_mode" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_mode"
xdebug.remote_port => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_port" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_port"
xdebug.remote_timeout => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_timeout" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_timeout"
xdebug.scream => Off => Off
xdebug.show_error_trace => Off => Off
xdebug.show_exception_trace => Off => Off
xdebug.show_local_vars => Off => Off
xdebug.show_mem_delta => This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.show_mem_delta" => This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.show_mem_delta"
xdebug.start_upon_error => default => default
xdebug.start_with_request => 1 => 1
xdebug.trace_enable_trigger => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.trace_enable_trigger" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.trace_enable_trigger"
xdebug.trace_enable_trigger_value => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.trace_enable_trigger_value" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.trace_enable_trigger_value"
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
xdebug.trace_output_dir => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.trace_output_dir" => This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.trace_output_dir"
xdebug.trace_output_name => trace.%c => trace.%c
xdebug.trigger_value => no value => no value
xdebug.var_display_max_children => 128 => 128
xdebug.var_display_max_data => 512 => 512
xdebug.var_display_max_depth => 3 => 3

【问题讨论】:

  • 可能是您的 Xdebug 或 PHP 设置。我的意思是 - 它在控制台中打印的原因(因为它只意味着打印到错误日志中)。请显示php -i(与phpinfo()相同)——目前主要对Xdebug部分和核心PHP(错误日志相关)感兴趣。
  • 至于“为什么它仍然存在”.. 你必须拥有xdebug.start_with_request = yes(这与 Xdebug v2 的xdebug.remote_autostart = yes 相同)——它告诉 Xdebug 尝试调试 每个脚本不管“调试我”标志。尝试禁用它并仅按需使用调试(例如,从 Xdebug 浏览器扩展设置的 IDE / cookie 启动时)。
  • 是的.. 我刚刚用其中的 x-debug 信息更新了问题
  • 是的,它有效。删除 xdebug.start_with_request = yes 解决了这个问题。
  • 请显示error_log PHP 设置的值(例如来自phpinfo(); 输出或只是ini_get('error_log');)。我敢打赌它会是空的(或者可能是一些不正确的位置)。

标签: php ubuntu-20.04 wsl-2 xdebug-3


【解决方案1】:

来自Xdebug的documentation关于此类错误:

在 Xdebug 尝试连接到调试客户端以启动调试会话时发生。

调试器无法连接到客户端。错误消息指出尝试了哪些主机和端口组合,以及通过哪些配置选项得出该结论。

一个例子:

无法连接到调试客户端。尝试过:::1:9003(来自REMOTE_ADDR HTTP 标头),localhost:9003(通过xdebug.client_host/xdebug.client_port 回退)

此消息表明 Xdebug 首先尝试使用 REMOTE_ADDR 标头中的::1:9003(IPv6 的本地主机),然后按照xdebug.client_hostxdebug.client_port 的配置退回到localhost:9003

建议的解决方案:

  • 检查您的调试客户端是否正在侦听指定的地址和端口。在 Linux 和 OSX 上,您可以使用netstat -a -n | grep LISTEN 进行检查。
  • xdebug.client_host 和/或xdebug.client_port 更改为调试客户端正在侦听的正确地址/主机名和端口。

【讨论】:

  • 哦,这也很有用,可以使用netstat -a -n | grep LISTEN确定它在哪里收听
【解决方案2】:

首先导致该消息的原因:

您有xdebug.start_with_request = yes(与 Xdebug v2 的xdebug.remote_autostart = yes 相同)。此选项告诉 Xdebug 尝试调试每个请求/脚本,而不管“调试我”标志。

如果 Xdebug 无法连接到调试客户端(来自 xdebug.client_hostxdebug.client_port 的值 .. 或自动检测到的主机,如果启用了 xdebug.discover_client_host)然后它会通知您。

如何防止它出现在我的屏幕/输出中:

Xdebug 使用标准 PHP 例程来编写此类警告(例如 standard PHP error_log() function)。通常这样的消息将被写入标准PHP's error log。看起来您根本没有在您的 php.ini (空值)中配置它,因此 PHP 将其发送到您的标准输出(因此您仍然有机会看到它,因为它可能很重要)。

解决方案是将PHP's error_log ini setting 指向某个有效位置,以便您在需要时读取它(路径取决于您的操作系统和发行版,例如error_log = /var/log/php_error.log 会很常见)。如果您根本不需要这样的日志(有其他日志系统)——请改用/dev/null 或类似的东西。


您也可以尝试xdebug.log_level = 0,但这应该会阻止 Xdebug 记录任何内容,即使您指定了xdebug.log


另请参阅 Xdebug 作者关于“为什么会这样工作”的解释:https://stackoverflow.com/a/65670743/783119

【讨论】:

  • 感谢您指出这一点,尽管它可以删除 xdebug.start_with_request = yes 这也很有用,因为有时我会使用 ini_set('display_errors', 1); 在脚本开头显示某些内容,如果没有抓住.
  • xdebug.log_level=0 是我的解决方案。
  • 谢谢。在我的情况下,这些潜在的 Xdebug 错误反过来又导致了 phpcs: Unknown error ocurred. Please verify that C:\Users\Nick\AppData\Roaming\Composer\vendor\bin\phpcs.bat --report=json -q --encoding=UTF-8 --error-severity=6 --warning-severity=6 C:\Bitnami\wampstack-7.4.12-0\apache2\htdocs\myfile.php - returns a valid json object. 形式的 phpcs 错误我有点担心我可能会错过哪些重要的 Xdebug 错误。
  • @NickHope AFAIK 没什么重要的。如果调试对您来说已经正常了,那么就不会错过任何重要的事情。
  • @LazyOne 我在我的 php.ini 中设置了一个 error_log 路径,但我的控制台仍然收到相同的错误。我确实必须设置xdebug.log_level=0 才能修复它。但是现在如果出现问题,我不会收到任何输出到我的error_log 路径吗?
【解决方案3】:

我正在使用: xdebug.start_with_request=trigger 在需要时触发 xdebug(使用浏览器 xdebug 扩展进行 Web 服务器调试)。

或者如果我需要调试 php 脚本(使用 cli),我使用 phpstorm 配置如下:

使用这种方法,我不会收到此错误,并且可以像往常一样使用 xdebug 日志。

【讨论】:

    【解决方案4】:

    不使用时禁用 xdebug 浏览器扩展。

    我使用 VSCode 调试器。在 IDE 中关闭调试后,我在每次访问页面时都会在日志中看到错误,因为我的 chrome 浏览器扩展程序仍在尝试调用 xdebug。

    尽管为 xdebug 设置了良好的 php.ini 设置,但仍会发生这种情况:

    xdebug.mode=debug
    

    xdebug.start_with_request=trigger
    

    两者都记录在这里:Xdebug: Documentation

    【讨论】:

      猜你喜欢
      • 2021-02-28
      • 2023-03-09
      • 1970-01-01
      • 1970-01-01
      • 2016-12-25
      • 1970-01-01
      • 2013-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多