0

Firstly I'll apologise for clogging up the internet with yet another post about Netbeans and XDebuug but after two weeks of trying to get XDebug to work connecting remotely from Windows 7 to my dev machine, I'm left with no alternative. FYI, I've done extensive research into the issue but have run out of quality search results to read.

In summary when trying to attach the debugger I get 'Attaching to 127.0.0.1:9000\r\nConnection refused.', If I try to debug a file through right-click/debug file I get 'Waiting for connection'

In detail here is my XDebug.ini file under /etc/php5/apache2/xdebug.ini:

zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so

xdebug.remote_enable = on

xdebug.remote_autostart = off
xdebug.remote_handler = dbgp
xdebug.remote_port = 9000
xdebug.remote_server = localhost
xdebug.remote_mode = req

xdebug.idekey = netbeans-xdebug
output_buffering = off

xdebug.remote_log = "/var/log/xdebug.log"

My system specs are:

My laptop:

  • Windows 7
  • Netbeans 7.4
  • Debug browser: Chrome Version 30.0.1599.101 m

My server:

  • Linux Debian Ubuntu 11.10
  • PHP 5.3.6-13ubuntu3.10
  • Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethan [Confirmed running under php_info()]

How i'm trying to connect:

Following Stuporglues tutorial, I have xdebug and netbeans configured to run on port 9000 (under xdebug.ini and netbeans->tools->options->php->debugging) using a putty connection with port 9000 forwarded as remote under ssh->tunnels (9000/127.0.0.1:9000).

I can see that the Linux server is listening:

james@XXX:/$ netstat -a -n | grep 9000
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN
tcp6       0      0 ::1:9000                :::*                    LISTEN

When I try to debug a file I can see that Netbeans is listening on port 9000

netstat -aon
...
TCP    127.0.0.1:9000         127.0.0.1:59691        ESTABLISHED     6744

Also, the browser (chrome) opens with the debugging parameter in the address bar correctly:

https://xxxxx.xxx/xxxxx/dMotor1_2PropZ.php?XDEBUG_SESSION_START=netbeans-xdebug

But Netbeans just hangs with 'waiting connection'

Things tried:

  • I've extensively checked all the applicable firewalls, disabling the windows bundled firewall, and also wiping out iptables and ip6tables on my server, no effect.
  • I've tried duplicating the project under http not https in case this was causing issues, no effect
  • All types of XDebug.ini settings
  • Disabling 'open browser' under project->properties->Run Configuration->Advanced->Debug Url and manually opening the page in chrome with the XDEBUG_SESSION_START parameter correctly appended, no effect
  • Under project->properties->Run Configuration->Advanced->Debug Url choosing 'ask every time' with the index.php setting under project->properties->Run Configuration blank, no effect
  • Under project->properties->Run Configuration manually appending the XDEBUG_SESSION_START argument as such: netbeans-xdebug, no effect
  • Rebooting my computer, restarting Apache and restarting my remote machine endlessly, no effect
  • Enabling 'silent debugging mode in chrome', no effect
  • Adding the '--remote-debugging-port=9000' option to chromes startup shortcut runpath, no effect
  • Installing PHPStorm to see if by I can get any further, no effect
  • Using different browsers (have tried Firefox and IE), no effect
  • Reinstalled XDebug, after using the wizard to ensure the version is compatible with my PHP release, no effect
  • Creating index.php in case this help, no effect
  • Setting timezone in php.ini file, no effect

Current theories:

Connection refused? Is there really something blocking the connection? If so, how would I find it? I've tried everything I can think of. Otherwise is this a default error message that's masking a completely different problem?

Further information:

Honestly, its probable I've missed something simple here and have dived far too deep to realise easily, this is the first time I've tried to get XDebug to work on a remote machine and my Linux admin and Netbeans experience is limited.

Even more strangely, I got it working once under the described configuration in my office, then I put my computer on standby and went home, at this point I was also able to run with debug once and then without changing any settings, the problems described above began.

XDebug log file has contained 'could not connect', but currently does not add new content.

Any help would be really appreciated.

Thanks in advance,

James

4

2 回答 2

1

您是否尝试过更改 remote_server INI 指令?

我的开发电脑上有 Win7,服务器上有 Ubuntu 12.04.3,我的 ini 包含以下 xdebug 指令:

[xdebug]
xdebug.auto_trace = 0
xdebug.collect_params = 1
xdebug.show_mem_delta = 1
xdebug.collect_params = 1

xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0

xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "MY_HOSTNAME"

它就像一个魅力

于 2013-10-28T14:34:45.990 回答
0

对于所有 WINDOWS 用户........

该技术基于 unix 世界,它使用 /etc/hosts 文件来解析包括 localhost 在内的所有主机名。

因此;即使在 Windows 上,它也在寻找位于 c:\windows\system32\drivers\etc 中的“hosts”文件。

编辑您的主机文件并添加本地主机或您希望 xdebug.remote_host 成为的任何主机。

例如

127.0.0.1 本地主机

192.168.0.101 abojmsi

这不仅可以解决这个问题,还可以解决几乎所有关于 apache 的问题。

于 2013-10-31T12:52:47.720 回答