XDEBUG session timeout with “Service Unavailable” message
Some Background
My application runs on a CentOS machine with Apache 2.4 and PHP 5.6 (from Remi’s repo), and I’m using PHP-FPM (via Apache proxy option) to handle the php files (not the Apache module). And I was trying to debug a remote PHP application (using xdebug) running on a VM.
I setup my IDE for remote debugging, and start setting some break points and going though the code, and right after 60 seconds (while I’m still running though the code and stepping over some lines) the browser will stop and display the message “Service Unavailable”.
I started with this xdebug setup,
[xdebug] xdebug.idekey=XDEBUG xdebug.remote_connect_back=1 xdebug.remote_enable=1 xdebug.remote_handler=dbgp ;xdebug.remote_host=192.168.160.1 xdebug.remote_mode=req xdebug.remote_port=9000 xdebug.remote_cookie_expire_time = 3600
I’m basically will start the xdebug service on my machine on port 9000, and I’m telling xdebug on the remote machine to connect back to the address the initiate the debug session (in this case the remote_host option will be ignored).
At first I though it was php/xdebug miss behaving, to I tried to play with the cookie_expire_time but the didn’t solved my problem, so I moved to look if it was PHP or the connection between Apache and the PHP layer, and this is what solved my problem.
TL;DR
<Proxy "fcgi://127.0.0.1:9000"> # Needed for XDEBUG, to allow long debug session. ProxySet timeout=900 </Proxy>
Resources
- Google search result | xdebug “service unavailable” timeout
- Troubleshooting PhpStorm debugging
- PhpStorm Video Tutorials
- https://github.com/geerlingguy/drupal-vm/issues/903
- http://stackoverflow.com/questions/4139794/why-does-my-netbeans-xdebug-session-timeout-after-period-of-inactivity/4613189#4613189
- Google search result | apache php-fpm proxy timeout
- Remi’s Forums – How do I set timeout when using Apache and PHP-FPM via SetHandler?
- http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?revision=1687783&view=markup#l2798
- https://bugzilla.redhat.com/show_bug.cgi?id=1222328