-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stream_select warning FD_SETSIZE #1631
Comments
OK, as I see now, this might be a duplicate to #1618. But do you see any disadvantages in deleting the stream_select if condition? As I understand, it should prevent a timeout under certain circumstances? |
This doesn't require recompiling PHP, but it does require being able to alter runtime file descriptor limits, usually via sysctl and ulimit, which you may also not have access to, but your ISP may be able to alter that. The origin of this use of stream select is here. You can see that it replaced a simpler timeout mechanism that failed in other ways. You could create a child class and override that usage (e.g. by reverting to the old implementation) as a workaround, but be aware that doing that may create other problems elsewhere. |
Very interesting thing is that:
Tested on the same machine. |
And, btw, in sysctl.conf we have
So file descriptors ar not limited at all... |
Btw, solution that @PDFCoder found (to comment |
I'd recommend double-checking what the apache user's file limits actually are, for example run |
I've come across this issue and it doesn't appear to depend on the user that is running Apache and their file limits, it also doesn't appear to depend on PHP, Apache and OpenSSL being recompiled to support more than 1024 file descriptors, I have tried to address this by re-building the Debian packages and on a server running these rebuilt packages the test script posted to this issue can be run and will open more that 1024 sockets if edited to do so (it won't open more than 1024 sockets with the versions of Apache and PHP Debian provides). This Plesk guide suggests that |
|
OK, so it's not that. Can you see if your PHP is built with its own FD limit, as @PDFCoder mentioned? |
I'm pretty sure we would have much larger issues if ulimit is only 1024... @Synchro |
This is how I checked the apt install -y php-dev
php-config --configure-options | sed 's/\s\+/\n/g' | grep enable-fd-setsize But having it set to a value higher than 1024 doesn't actually appear to help… |
I got just empty output with it, @chriscroome |
There is no enable-fd-setsize |
Empty output means it has the default of 1024 as far as I could work out. |
I you have a dev / test Stretch server feel free to try the debs I built which are available here https://deb.webarch.net/ they have |
I'm not sure at what point the limit is applied - for example if it's per-process and you're running under a non-threaded SAPI like mod_php, you're less likely to run into it than if you're using a threaded single process like PHP-FPM. I'd also expect that if you're running into a limit like this, it's likely to occur in at least slightly random random places, rather than consistently the same place. It would be useful to get someone with PHP internals knowledge on this. |
Both Apache (with mod_php) and PHP-FPM are configured to switch process UID and GID to user - so we do not run scripts as www-data, for sure. And as I previously said, there is no issues if script is run through PHP-FPM. Again, I expect pretty much issues if scripts are reaching ulimits... but we don't have any issues, even we hosts 200 sites on that server. |
I'm using Apache 2 ITK MPM, it is in Debian, I haven't come across mod_ruid2 before, I see that this is also in Debian, I guess they do more-or-less that same thing… |
Same trouble here on ubuntu 18.04, apache2 and thousands of virtual hosts using their own UID and GID with mpm_itk. |
It's not the library opening "so many" files. It's the library opening 1 file, and PHP not having enough file descriptors available to let it happen. |
this was helped me |
The problem is caused because of a |
I don't know the internals implications of the stream_select, but I do recall that it was introduced in PHPMailer to avoid a different bug in #604. If you have a better and more reliable way to implement this, PRs are welcome. |
We're also running up against this issue, and would love to see a solution that doesn't involve having to recompile PHP. |
As mentioned earlier in this thread, you can revert to the old behaviour (complete with its accompanying, but different bugs) by providing your own child class that overrides just the |
Are we sure the old version is still buggy, because it was correct php, but there were problems in the php implementation, which might have been fixed. |
Could be, but I don't know enough about PHP internals to judge. It could do with someone who actually knows rather than guessing. Also remember we still maintain compatibility back to PHP 5.5. |
We run into a problem on our live server (debian, PHP 7.1) with phpmailer 6.0.6 – everything has been working fine there with version 5.2.x.
If we try to send an email (can even be a simple text, or the smtp_check of the sample files!) we get a php warning and the server is running into a timeout:
PHP Warning: stream_select(): You MUST recompile PHP with a larger value of FD_SETSIZE.
It is set to 1024, but you have descriptors numbered at least as high as 1314.
--enable-fd-setsize=2048 is recommended, but you may want to set it
to equal the maximum number of open files supported by your system,
in order to avoid seeing this error again at a later date. in /home/www/xxx/phpmailer/src/SMTP.php on line 1125
Our hoster won't recompile PHP, so the suggested solution won't work.
We made some futher tests and found out, that the stream_select if condition in line 1125 didn't exist in phpmailer 5.2.x. If we delete this condition, everythings seems to work fine again (as far as we could test it now; with bigger mails, attachments).
if (!stream_select($selR, $selW, $selW, $this->Timelimit)) { …
If we set the timelimit of the function to a small value (like 3 seconds) the server loops a warning to the error log until the script is terminated:
PHP Warning: stream_select(): No stream arrays were passed in /home/www/xxx/phpmailer/src/SMTP.php
So what is the idea behind the stream_select condition? Is there a fix to this problem?
On other servers/accounts (same setup) the problem does not appear …!? Any idea?
The text was updated successfully, but these errors were encountered: