13
8
I am running Mac OS X 10.9.4, including the builtin apache2 webserver with PHP 5.5.14 from brew (packages: php55, php55-intl, php55-pdo-pgsql, php55-xdebug).
When running this setup it works quite well. However, after some time, I will run on 403 errors for every request. I have looked up the apache error log, and found something like the following:
[Fri Jul 25 05:28:18 2014] [error] [client 127.0.0.1] PHP Warning: require_once(/Users/daniel/Development/massiveart/sulu-complete/app/bootstrap.php.cache): failed to open stream: Too many open files in /Users/daniel/Development/massiveart/sulu-complete/web/website.php on line 10, referer: http://sulu.lo/de
[Fri Jul 25 05:28:18 2014] [error] [client 127.0.0.1] PHP Stack trace:, referer: http://sulu.lo/de
[Fri Jul 25 05:28:18 2014] [error] [client 127.0.0.1] PHP 1. {main}() /Users/daniel/Development/massiveart/sulu-complete/web/website.php:0, referer: http://sulu.lo/de
[Fri Jul 25 05:28:18 2014] [error] [client 127.0.0.1] PHP Fatal error: require_once(): Failed opening required '/Users/daniel/Development/massiveart/sulu-complete/web/../app/bootstrap.php.cache' (include_path='.:/usr/local/Cellar/php55/5.5.14/lib/php') in /Users/daniel/Development/massiveart/sulu-complete/web/website.php on line 10, referer: http://sulu.lo/de
[Fri Jul 25 05:28:18 2014] [error] [client 127.0.0.1] PHP Stack trace:, referer: http://sulu.lo/de
[Fri Jul 25 05:28:18 2014] [error] [client 127.0.0.1] PHP 1. {main}() /Users/daniel/Development/massiveart/sulu-complete/web/website.php:0, referer: http://sulu.lo/de
[Fri Jul 25 05:28:40 2014] [crit] [client 127.0.0.1] (24)Too many open files: /Users/daniel/Development/massiveart/sulu-complete/web/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable, referer: http://sulu.lo/de
[Fri Jul 25 05:28:41 2014] [crit] [client 127.0.0.1] (24)Too many open files: /Users/daniel/Development/massiveart/sulu-complete/web/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable, referer: http://sulu.lo/de
[Fri Jul 25 05:28:41 2014] [crit] [client 127.0.0.1] (24)Too many open files: /Users/daniel/Development/massiveart/sulu-complete/web/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable, referer: http://sulu.lo/de
[Fri Jul 25 05:28:41 2014] [crit] [client 127.0.0.1] (24)Too many open files: /Users/daniel/Development/massiveart/sulu-complete/web/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable, referer: http://sulu.lo/de
[Fri Jul 25 05:28:45 2014] [crit] [client 127.0.0.1] (24)Too many open files: /Users/daniel/Development/massiveart/sulu-complete/web/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable, referer: http://sulu.lo/de
[Fri Jul 25 05:28:45 2014] [crit] [client 127.0.0.1] (24)Too many open files: /Users/daniel/Development/massiveart/sulu-complete/web/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable, referer: http://sulu.lo/de
It looks to me like the file cannot be read anymore, and it returns the 403 somehow. I already found out about certain limits, but launchctl returns I have an unlimited hard limit on open files:
~ $ launchctl limit
cpu unlimited unlimited
filesize unlimited unlimited
data unlimited unlimited
stack 8388608 67104768
core 0 unlimited
rss unlimited unlimited
memlock unlimited unlimited
maxproc 709 1064
maxfiles 256 unlimited
I have also already tried to set the maxfiles to 4096 with the command launchctl limit maxfiles 4096 16384
, but the issue still returns after some time. Any idea what else I can check?
UPDATE:
When running the lsof -c httpd
command as suggested by Gordon Davisson, I can see that there are loads of entries like the following:
httpd 1361 _www 15u IPv4 0xb306b48659f63853 0t0 TCP localhost:50603->localhost:cslistener (CLOSED)
I can say that the application I use is using websockets, and is also using a fallback when websockets are not available or the counterpart is not running on the server. What confuses me is the (CLOSED)
-part, why is it still listed?
UPDATE: After some time I looked up the cslistener port, which actually is 9000, which again is which port xdebug is listening for remote debugging. So I guess I have got some wrong configuration there, or it is a bug in xdebug (I am using XDebug 2.2.5, installed by brew)
Not really a solution, but I think it answers the question – Daniel Rotter – 2014-11-06T09:44:43.070
Basically, Xdebug is leaking file descriptors for connection listeners (sorry if this is technically incorrect, that's the idea) when the debugging client is not open. To solve the problem, make sure the debugger client is open when the remote debugger starts a debugging session. Of course, a better solution would be a fix to the bug by the developers. – mcdado – 2014-11-14T10:49:29.130
This also happens with some debuggers open (for instance PhpStorm). Hopefully they'll fix it :) – Steve Tauber – 2014-11-18T09:56:32.040
This is pretty major, I hope a fix will be issued soon. – Hubert Perron – 2014-11-20T15:33:16.637
1Another workaround is to set
xdebug.remote_enable=0
inphp.ini
to turn of xdebug remote connections when not using them. Apache restart required. – Gregory Cosmo Haun – 2016-02-02T23:05:19.703I'm running 2.4.0 and I am still running into this problem with PHP 5.6 – Jeff – 2016-06-16T01:34:41.563