简体   繁体   English

循序渐进:如何对客户端 IDE 的连接进行 Xdebug 故障排除

[英]Step-by-step: How to do Xdebug troubleshooting connection to client IDE

BACKGROUND背景

Using Xdebug with PHP and Komodo IDE, and Eclipse PDT.将 Xdebug 与 PHP 和 Komodo IDE 以及 Eclipse PDT 结合使用。

Xdebug is installed on the server and working properly. Xdebug 已安装在服务器上并正常工作。 This is confirmed because the Xdebug code commands work as expected when inserted into PHP files on the server.这是因为 Xdebug 代码命令在插入服务器上的 PHP 文件时按预期工作。

PROBLEM问题

Connecting to the client workstation is not working, and it is difficult to determine why because it fails with multiple IDEs.连接到客户端工作站不起作用,并且很难确定原因,因为它在多个 IDE 下失败。

QUESTION问题

It would be nice to have a step-by-step checklist to troubleshoot the case where you know Xdebug is installed and working on the server, but the client does not connect.如果您知道 Xdebug 已安装并在服务器上工作,但客户端未连接,则最好有一个分步检查表来排除故障。

Can anyone help add to this to make a comprehensive troubleshooting checklist?任何人都可以帮助添加到此以制作全面的故障排除清单吗?

Specifically, is there any bare-bones way to make sure the network traffic is reaching the client, and is correctly formatted in the way the IDE expects to see the data?具体来说,是否有任何简单的方法来确保网络流量到达客户端,并以 IDE 期望查看数据的方式正确格式化?

  • SSH into web host and try to reach the client:通过 SSH 连接到 Web 主机并尝试访问客户端:

    • can host reach client at all?主机可以访问客户端吗? (ping -c 5 xxx.xxx.xxx.xxx ) (ping -c 5 xxx.xxx.xxx.xxx )
    • can host reach port 9000?主机可以到达9000端口吗? (nmap -p 9000 xxx.xxx.xxx.xxx) (nmap -p 9000 xxx.xxx.xxx.xxx)
    • if the above two succeed, what should the output be?如果以上两个成功,输出应该是什么?
    • if the above two fail, what is the next troubleshooting step?如果以上两个都失败了,下一步的故障排除步骤是什么?
  • Verify settings of software-based firewall on client验证客户端上基于软件的防火墙的设置

  • Verify settings of iptables on linux host在 linux 主机上验证 iptables 的设置
  • Verify hardware firewall b/t client and host验证硬件防火墙 b/t 客户端和主机

GOAL目标

The goal is to find some solution where the person on the client machine can at least confirm that something is reaching the client without having to determine whether the IDE is the problem, since IDE is another level of complexity that may be introducing problems.目标是找到某种解决方案,使客户端计算机上的人员至少可以确认某些东西正在到达客户端,而不必确定 IDE 是否有问题,因为 IDE 是另一个可能引入问题的复杂级别。

This is something I would definitely want to include in the Xdebug documentation.这是我绝对希望包含在 Xdebug 文档中的内容。 I think it would work best to have many people collaborate on this, so I've created a file in the xdebug.org github repository ( https://github.com/derickr/xdebug.org/blob/master/html/docs/tutorials/troubleshooting.rest ) to collect tips.我认为最好让很多人对此进行协作,因此我在 xdebug.org github 存储库中创建了一个文件 ( https://github.com/derickr/xdebug.org/blob/master/html/docs /tutorials/troubleshooting.rest ) 来收集提示。 Feel free to fork and extend!随意分叉和扩展!

On the Xdebug side, in the upcoming version (2.2) it already dumps in its xdebug.remote_log file a couple of extra diagnostics such as whether it tried to connect and whether the connection was accepted or denied.在 Xdebug 方面,在即将发布的版本 (2.2) 中,它已经在其 xdebug.remote_log 文件中转储了一些额外的诊断信息,例如它是否尝试连接以及连接是被接受还是被拒绝。

You can use the debugclient utility to determine if the client can receive Xdebug connections, as you can read in the Xdebug documentation :您可以使用debugclient实用程序来确定客户端是否可以接收 Xdebug 连接,您可以在Xdebug 文档中阅读:

Before you start your script you will need to tell your client that it can receive debug connections, please refer to the documentation of the specific client on how to do this.在开始脚本之前,您需要告诉客户端它可以接收调试连接,请参阅特定客户端的文档以了解如何执行此操作。 To use the bundled client simply start it after compiling and installing it.要使用捆绑的客户端,只需在编译和安装后启动它。 You can start it by running "debugclient".您可以通过运行“debugclient”来启动它。 If you want to use the GDB commandset to debug your scripts, make sure you use a debugclient as bundled with Xdebug 1.3 as the one bundled with Xdebug 2 only works with the DBGp commandset.如果您想使用 GDB 命令集来调试您的脚本,请确保您使用与 Xdebug 1.3 捆绑的调试客户端,因为与 Xdebug 2 捆绑的调试客户端仅适用于 DBGp 命令集。 When the debugclient starts it will show the following information and then waits until a connection is initiated by the debug server:当 debugclient 启动时,它会显示以下信息,然后等待调试服务器发起连接:

Xdebug Simple DBGp client (0.10.0)
Copyright 2002-2007 by Derick Rethans.
- libedit support: enabled
Waiting for debug server to connect.

After a connection is made the output of the debug server is shown:建立连接后,调试服务器的输出显示:

Connect
<?xml version="1.0" encoding="iso-8859-1"?>
<init xmlns="urn:debugger_protocol_v1"
      xmlns:xdebug="http://xdebug.org/dbgp/xdebug"
      fileuri="file:///home/httpd/www.xdebug.org/html/docs/index.php"
      language="PHP"
      protocol_version="1.0"
      appid="13202"
      idekey="derick">
  <engine version="2.0.0RC4-dev"><![CDATA[Xdebug]]></engine>
  <author><![CDATA[Derick Rethans]]></author>
  <url><![CDATA[http://xdebug.org]]></url>
  <copyright><![CDATA[Copyright (c) 2002-2007 by Derick Rethans]]></copyright>
</init>
(cmd)

You can find more information about the Xdebug 2 initialization protocol here .您可以 在此处找到有关 Xdebug 2 初始化协议的更多信息。
A further reference: Howto check xdebug installation .进一步参考: 如何检查 xdebug 安装
Unfortunately the debugclient utility is provided only in source form, so you have to build the executable by yourself;不幸的是,debugclient 实用程序仅以源代码形式提供,因此您必须自己构建可执行文件; this can be done either on Linux (see INSTALL ) and Windows (with Visual Studio - see debugclient.dsp ).这可以在 Linux(请参阅INSTALL )和 Windows(使用 Visual Studio - 请参阅debugclient.dsp )上完成。
XAMPP includes a compiled version in xampp/php/debugclient.exe . XAMPP 在xampp/php/debugclient.exe包含一个编译版本。

Netbeans has a very thorough documentation that also covers how to troubleshoot such problems: Netbeans 有一个非常详尽的文档,其中还介绍了如何解决此类问题:

http://wiki.netbeans.org/HowToConfigureXDebug http://wiki.netbeans.org/HowToConfigureXDebug

Windows users disable your firewall and then try again. Windows 用户禁用您的防火墙,然后重试。 If it works, allow Java(TM) Platform SE binary through firewall then enable it again.如果它有效,请允许 Java(TM) Platform SE 二进制文件通过防火墙,然后再次启用它。 It will work just fine!它会工作得很好!

Thank you for the commands, they were very useful on debugging.谢谢你的命令,它们对调试非常有用。

be careful about firewalls for remote debug sessions.小心远程调试会话的防火墙。 I diagnosed my problem by using telnet to checkout 9000 port status and found that preventations by firewall.我通过使用 telnet 检查 9000 端口状态来诊断我的问题,并发现防火墙进行了预防。

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

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