简体   繁体   English

Xdebug:[Step Debug] 无法连接到调试客户端。 试过:localhost:9003(通过 xdebug.client_host/xdebug.client_port 回退):-(

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

What is the workaround of this message for xdebug ang php?此消息对于 xdebug ang php 的解决方法是什么?

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

This message showup when I run composer update on WSL2 installed with UBUNTU 20.01 .当我在安装了UBUNTU 20.01WSL2上运行composer update时,会显示此消息。

My current php version is php8 and xdebug3我当前的 php 版本是php8xdebug3

Update:更新:

This is the x-debug section这是 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

What causes that message in the first place:首先是什么导致该消息:

You have xdebug.start_with_request = yes (which is the same as xdebug.remote_autostart = yes for Xdebug v2).你有xdebug.start_with_request = yes (这与 Xdebug v2 的xdebug.remote_autostart = yes相同)。 This option tells Xdebug to try to debug every single request/script regardless of the "debug me" flag.此选项告诉 Xdebug 尝试调试每个请求/脚本,而不管“调试我”标志。

If Xdebug fails to connect to the debug client (values from xdebug.client_host & xdebug.client_port .. or autodetected host if xdebug.discover_client_host is enabled) then it notifies you about that.如果 Xdebug 无法连接到调试客户端(来自xdebug.client_hostxdebug.client_port的值 .. 或者如果启用了xdebug.discover_client_host则自动检测到主机),那么它会通知您。

How to prevent it from appearing on my screen/in the output:如何防止它出现在我的屏幕上/output 中:

Xdebug uses standard PHP routines to write such warnings (eg standard PHP error_log() function ). Xdebug 使用标准 PHP 例程来编写此类警告(例如标准 PHP error_log() function )。 Normally such a message will be written to the standard PHP's error log .通常这样的消息会被写入标准PHP 的错误日志中。 Looks like you do not have it configured at all in your php.ini (empty value) therefore PHP sends it to your standard output instead (so you still can have a chance to see it, as it might be important).看起来你根本没有在你的php.ini (空值)中配置它,因此 PHP 将它发送到你的标准 output 代替(所以你可能仍然有机会看到它)。

The solution is to point PHP's error_log ini setting to some valid location so you can read it when needed (path depends on your OS & distro, eg error_log = /var/log/php_error.log would be very common).解决方案是将PHP 的error_log ini 设置指向某个有效位置,以便您可以在需要时读取它(路径取决于您的操作系统和发行版,例如error_log = /var/log/php_error.log会很常见)。 If you do not need such log at all (have other logging system in place) -- use /dev/null or something similar instead.如果您根本不需要这样的日志(有其他日志系统)——请改用/dev/null或类似的东西。


You can also try xdebug.log_level = 0 but this should prevent Xdebug from logging anything, even if you specify xdebug.log .您也可以尝试xdebug.log_level = 0但这应该会阻止 Xdebug 记录任何内容,即使您指定xdebug.log

From the documentation of Xdebug about this kind of errors:从有关此类错误的 Xdebug文档中:

Occurs when Xdebug is trying to connect to a debuging client to start a debugging session.当 Xdebug 尝试连接到调试客户端以启动调试 session 时发生。

The debugger could not make a connection to the client.调试器无法与客户端建立连接。 The error message indicates which host and port combinations were tried, and through which configuration options it came to that conclusion.错误消息指出尝试了哪些主机和端口组合,以及通过哪些配置选项得出该结论。

An example:一个例子:

Could not connect to debugging client.无法连接到调试客户端。 Tried: ::1:9003 (from REMOTE_ADDR HTTP header), localhost:9003 (fallback through xdebug.client_host / xdebug.client_port )尝试过: ::1:9003 (来自REMOTE_ADDR HTTP 标头), localhost:9003 (通过xdebug.client_host / xdebug.client_port回退)

This message indicates that Xdebug first tried to use ::1:9003 (IPv6's localhost) from the REMOTE_ADDR header, and then it fell back to localhost:9003 as configured with xdebug.client_host and xdebug.client_por t.此消息表明 Xdebug 首先尝试使用来自 REMOTE_ADDR header 的::1:9003 (IPv6 的 localhost),然后它回退到配置有xdebug.client_hostxdebug.client_porlocalhost:9003

Suggested solutions:建议的解决方案:

  • Check whether your debugging client is listening on the indicated address and port.检查您的调试客户端是否正在侦听指定的地址和端口。 On Linux and OSX, you can use netstat -a -n | grep LISTEN在 Linux 和 OSX 上,您可以使用netstat -a -n | grep LISTEN netstat -a -n | grep LISTEN to check. netstat -a -n | grep LISTEN检查。
  • Change xdebug.client_host and/or xdebug.client_port to the right address/hostname and port of where the debugging client is listening.xdebug.client_host和/或xdebug.client_port更改为调试客户端正在侦听的正确地址/主机名和端口。

I'm using: xdebug.start_with_request=trigger to trigger xdebug when I need it(with use of browser xdebug extension for web server debugging).我正在使用: xdebug.start_with_request=trigger在需要时触发 xdebug(使用浏览器 xdebug 扩展进行 web 服务器调试)。

Or if I need to debug php script(using cli), I use phpstorm with configuration like this:或者如果我需要调试 php 脚本(使用 cli),我使用 phpstorm 配置如下:

在此处输入图像描述

With this approach, I don't get this error and can use xdebug logs as always.使用这种方法,我不会收到此错误,并且可以像往常一样使用 xdebug 日志。

Disable the xdebug browser extension when you aren't using it.不使用时禁用 xdebug 浏览器扩展。

I use the VSCode debugger.我使用 VSCode 调试器。 When debugging was off in the IDE I was seeing the error in the log on every page visit because my chrome browser extension was still trying to invoke xdebug.当 IDE 中的调试关闭时,我在每次访问页面时都在日志中看到错误,因为我的 chrome 浏览器扩展程序仍在尝试调用 xdebug。

This happens despite having good php.ini settings for xdebug like:尽管为 xdebug 设置了良好的 php.ini 设置,但仍会发生这种情况:

xdebug.mode=debug

or或者

xdebug.start_with_request=trigger

Both documented here: Xdebug: Documentation两者都记录在这里: Xdebug:文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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