Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx php-fpm xdebug netbeans can start only one debug session

In the past, I've used apache+mod_php+xdebug+netbeans for development my website (server is my local machine, running Debian Squeeze), with pleasure - xdebug worked just as expected, debug sessions could be started and stopped any time, when I need it. But, when I moved to nginx+php_fpm+xdebug+netbeans I've experienced some problems with debugging.

  1. My debug session could be very long (much more than 30 seconds) and it seems, that nginx couldn't wait so long, it shows "504 Gateway timeout error". I've tried lots of recommendations for solve this, but no luck. Though, it is not a very important for me, because of debugging session itself continues to run, and it's just a little uncomfortable thing.
  2. My debug session could be run only once, so, if I stop it, and try to launch debugging again, netbeans couldn't accept connection from xdebug (it writes "Waiting for xdebug connection" and it is forever). After restart of netbeans the debug session could be started again normally.
  3. In come cases, that I couldn't understand, the debugging is "turning on for all php scripts" and prevent's any other scripts to run. For example, I start debug session on my website's http://mysite.local/index.php and working with it. After some time, I noticed, that my adminer (placed on intranet.local/adminer.php) doesnt run, the browser tries to load page for some time, and than shows "504 Gateway timeout error". If I see this behavior, I could just stop xdebug debug session in netbeans, and all other scripts starting to operate normally.

Now, when I writing this question, I made some investigations, and found, that, if I start debug session for some seconds, after that stop it, and start again - it starts normally. It seems like the problem appears after some time of active debugging.

My system and apps: Debian squeeze:2.6.32-5-686 Nginx: 1.4.1 (from dotdeb repository) php5-fpm: 5.3.26-1~d (from dotdeb repository) php5-xdebug: 5.3.26-1~d (from dotdeb repository) netbeans: 7.3

My config:

  1. nginx base config: https://gist.github.com/MihanEntalpo/6229801
  2. nginx website config file: https://gist.github.com/MihanEntalpo/6229781
  3. fastcgi_params file: https://gist.github.com/MihanEntalpo/d93fd4105573e1eda56f
  4. php-fpm pool config file: https://gist.github.com/MihanEntalpo/6229820
  5. php-fpm xdebug config file: https://gist.github.com/MihanEntalpo/6229836
  6. netbeans: options, that was just the same with apache server:
    • Break on first line = OFF
    • Evalution in popup window = ON
    • Show requesting URL's = ON
    • Port = 9000

Record in nginx's error log file, when it cannot wait for script being debugged, or other script, locked by the problem #3, mentioned early:

2013/08/14 14:40:16 [error] 4822#0: *111 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.100.1, server: intranet.local, request: "GET /adminer.php?username=root&db=devel&table=user HTTP/1.1", upstream: "fastcgi://127.0.0.1:9999", host: "intranet.local", referrer: "https://intranet.local/adminer.php?username=root&db=devel"

php-fpm's logs doesn't contains ANY error messages...

I don't like to disturb anyone with my problems, and always trying to solve it by myself. But in this case, I'm fighting with this ones for some MONTHS without luck... If anyone faced this problems, or have working config for using with nginx+php-fpm+xdebug+netbeans - please help me :)

like image 375
MihanEntalpo Avatar asked Aug 14 '13 10:08

MihanEntalpo


People also ask

Why is Xdebug not working?

Xdebug cannot connect to PhpStorm This means that Xdebug tries to connect to the host and can't make the connection. To fix the issue, set xdebug. remote_connect_back=0 ( xdebug. discover_client_host=false for Xdebug 3) and make sure that xdebug.

How do I know if Xdebug is working?

Verify that Xdebug is properly running by checking again with phpinfo() or php -v as explained above. Note that 9003 is the default port. If this port is used by another service on your system, change it to an unused port. After adding these settings, restart your webserver again.


1 Answers

Thank you, everyone who tried to think in the direction of my problem. I've solve it successfully.

  1. First problem (with 504 error) could be solved by nginx option fastcgi_read_timeout, for example, it could be fastcgi_read_timeout 600; for tell nginx that it should wait for 600 seconds. It should be placed to host's config file, or to /etc/nginx/fastcgi_params (in Debian)
  2. Second problem was caused by option in my xdebug.conf: xdebug.remote_autostart=1;, it should be xdebug.remote_autostart=0;. I doesn't understand the real meaning of this option, but it does following: Any php script automatically trying to connect to debugger (netbeans in my case). So, in some case, netbeans loses a connection, and when I press "Start debugging", it doesn't know, that new connection should be opened, and waiting for xdebug client forever. Now, with the mentioned option, I can start and stop debugging any time when I need it.
  3. Third problem had the same source, as the second one. All others scripts, running on my server have tried to connect to netbeans, but with lost connection it was senseless.

Anyway, I hope this would help someone, who want to solve similar problems. StackOverflow helped me by forcing me to definitely describe my problem, and in this process I've gained new ideas on what to try.

like image 125
MihanEntalpo Avatar answered Sep 17 '22 17:09

MihanEntalpo