readv() failed on PROPFIND request while reading php://input (PHP 7, nginx) - php

After upgrading my Server to PHP 7 I get several errors while running ownCloud in its current version 8.1.1.
I tried to figure out what the problem is and I came down to Sapi.php of Sabre lib.
I wrote a very small test script to isolate the error. While running the following code using a PROPFIND request, I see errors in the log and I don't get any output out of php://input.
<?php
fopen("php://input", 'r+');
echo "Done";
?>
Request using cURL:
curl -i -X PROPFIND https://cloud.example.com/readv-demo.php -d 'Demo'
Error in nginx error log:
*285599 readv() failed (104: Connection reset by peer) while reading upstream, client: 5.35.252.37, server: cloud.example.com, request: "PROPFIND /readv-demo.php HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "cloud.example.com"
The server worked like a charm using PHP 5.6 and I tried to run PHP 7 without modifications. Everything on server-side is fine but this error.
I also tried suggestions to get around readv() errors and modified several settings like:
max_input_time = ...
max_execution_time = ...
default_socket_timeout = ...
request_terminate_timeout = ...

Related

How to get PHP 8.1 to recognize curl_init?

I know this may seem similar to many questions already out there, but I've read dozens and I am still experiencing the same issue. My code works fine on my local machine, and my Raspberry Pi was configured by the exact same setup script, but it doesn't work on the Pi.
My OS is Raspbian 10 (Buster) with kernel version 5.10.103-v7l+. I am running PHP 8.1, along with the other packages in the following command: sudo apt install -y php8.1-common php8.1-cli php8.1-fpm php8.1-xml php8.1-curl
php -m lists curl and php -i and phpinfo() show that cURL is installed and enabled:
cURL support => enabled
cURL Information => 7.64.0
I know cURL is installed and enabled, so how do I get my PHP to recognize and use the package? It works perfectly on my local Linux box but on the Pi it just doesn't. I have restarted my server and my entire machine and neither made a difference. I have ran sudo apt update && sudo apt upgrade and everything is at the most recent version.
The 'problematic' snippet of code on my server is the following:
require "vendor/autoload.php";
use Symfony\Component\Panther\Client;
$options = [
"--headless",
"--window-size=1200,1100",
"--no-sandbox",
"--disable-gpu",
"--disable-dev-shm-usage",
];
$query = urlencode($_GET["q"]);
$url ="/search?hl=en&tbo=d&site=&source=hp&q=".$query;
$client = Client::createChromeClient("/usr/lib/chromium-browser/chromedriver", $options, [], "http://www.google.com");
$client->request("GET", $url);
My full error log is:
*168 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function Facebook\WebDriver\Remote\curl_init() in /var/lib/jenkins/workspace/url-here.com/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:190
Stack trace:
#0 /var/lib/jenkins/workspace/url-here.com/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(100): Facebook\WebDriver\Remote\HttpCommandExecutor->__construct()
#1 /var/lib/jenkins/workspace/url-here.com/vendor/symfony/panther/src/ProcessManager/ChromeManager.php(75): Facebook\WebDriver\Remote\RemoteWebDriver::create()
#2 /var/lib/jenkins/workspace/url-here.com/vendor/symfony/panther/src/Client.php(117): Symfony\Component\Panther\ProcessManager\ChromeManager->start()
#3 /var/lib/jenkins/workspace/url-here.com/vendor/symfony/panther/src/Client.php(521): Symfony\Component\Panther\Client->start()
#4 /var/lib/jenkins/workspace/url-here.com/vendor/symfony/panther/src/Client.php(273): Symfony\Component\Panther\Client->get()
#5 /var/lib/jenkins/workspace" while reading response header from upstream, client: 96.244.127.121, server: url-here.com, request: "GET /googleSearch.php?q=test HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.0-fpm.sock:", host: "url-here.com", referrer: "https://url-here.com/apps/browser.html"
Any and all help would be appreciated, I've been struggling with this one for a while. I would just avoid using curl_init() if I could, but unfortunately as you can see the function is called in a library that my project depends on.
This line from the error log indicates what the problem most likely is:
#5 /var/lib/jenkins/workspace" while reading response header from upstream, client: 96.244.127.121, server: url-here.com, request: "GET /googleSearch.php?q=test HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.0-fpm.sock:", host: "url-here.com", referrer: "https://url-here.com/apps/browser.html"
You've got PHP 8.0 here, but you've installed Curl for PHP 8.1. You need to check your FPM or server configuration.
I think you're using Nginx. If that's correct then this article might be helpful. Specifically you'll want to look in:
/etc/nginx/sites-available to check which socket is used
/etc/php/VERSION/fpm/pool.d to check what sockets are available

Error on Kafka producer when application logs transferring to Kafka consumer

I have configured 3 Instances for a basic start to configure Kafka as sending Application logs to another machine.
There are PHP logs are transferring.
I have installed PHP, Nginx, PHPrdKafka, kafka_2.11-1.0.1., librdkafka, libsasl2-dev, libssl-dev, zlib1g-dev, libpthread-stubs0-dev, build-essential.
1 instance is working as producer, 2nd working as a broker and the last working as a consumer. When I start to test logs were continuously going to the consumer but the load on producer was getting high and an error occurs on producer:
2018/03/23 07:07:50 [error] 9819#9819: *539 connect() to
unix:/run/php/php7.0-fpm.sock failed (11: Resource temporarily
unavailable) while connecting to upstream, client: 35.190.64.128,
server: api-useast.midarexdigital.com, request: "POST
/rtb/70b4bf164fd840f80afe320b1ad98234 HTTP/1.1", upstream:
"fastcgi://unix:/run/php/php7.0-fpm.sock:", host:
"exchange.adnexus.mobi".
help me out with this.I am not getting any Clue.

I can't send user mail on WordPress

I almost give up what is wrong.
I've setup web server by using nginx.
But I can't send user mail on WordPress.
When I create user or reset password, WordPress must stop.
The environment is bellow.
Ubuntu0.16.04.1
Nginx 1.12.1
PHP 7.0.1
FPM/FastCGI
postfix 3.1.0
(I can send mail by 'mail' command.)
WordPress 4.4.2
Nginx Erro log is bellow----
PHP message: PHP Fatal error: require_once(): Failed opening required
'/var/www/html/cms/wp-includes/class-phpmailer.php'
(include_path='.:/usr/share/php') in
/var/www/html/cms/wp-includes/pluggable.php on line 275" while reading
response header from upstream, client: {global_ip}, server: {domain},
request: "POST /cms/wp-admin/user-edit.php HTTP/1.1", upstream:
"fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "{host_name}",
referrer:
"/cms/wp-admin/user-edit.php?user_id=2&wp_http_referer=%2Fcms%2Fwp-admin%2Fusers.php"
Any help or hint?
Thanks every one.It was solved.
When I install WordPress ,I've used "sudo apt get wordpress",and copy them to html root.
I don't know why ,(I might not use 'cp' command with sudo )
'class-phpmailer.php' and 'class-phpmailer.php' were not moved properly.
So that when the system use wp_mail() function , the WordPress was stop.
That's all.Thanks a lot!

No script name passed to php-fpm via nginx/FastCGI

I run a PHP 5.5/5.6 instance over php-fpm without any problems (unix sockets and nginx).
Today I compiled PHP 7 and also started it as a third PHP instance. While requests get served fine with the PHP 5.5/5.6 instances for the PHP 7 instance I get:
WARNING: pid 2582, fpm_request_check_timed_out(), line 277: [pool www0] child 2813, script '' (request: " ") execution timed out (120.018160 sec), terminating
in my php-fpm log file and
[error] 1889#0: *4 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: xxx.xxx.xxx.20, server: localhost, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php70-fpm.sock:", host: "xxx.xxx.xxx.21"
in my nginx error log file.
I use fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name which also works for the PHP 5.6 instance. Although the script filename for PHP 7 seems to be empty. I'm requesting a script /info.php.
Is there any difference between using PHP 5.x and 7.0 with php-fpm?
UPDATE
At least I'm not the only one who is facing those problems as it seems. I opened a bug report here: https://bugs.php.net/bug.php?id=69850
There is also a very similar (probably identical) bug already reported over here: https://bugs.php.net/bug.php?id=69875 (thx to #crypticツ)
UPDATE 2
Try the newest alpha2. The bug is fixed there. Unix sockets work now like a charm again.
I am not sure if this can be considered as answer, but at this moment, when I am writing this answer, the bug you have raised has been deemed confirmed by the PHP Team:
[2015-06-23 12:47 UTC] remi#php.net
I confirm
PHP 5.6.10 works
PHP 7.0.0-dev (Jun 17 2015)
- network socket: OK.
- UDS: broken
Update: I just saw that you are aware of the same too!

Nginx and Noisy PHP Error Log

Whenever a PHP error occurs or the error_log() function is used in PHP on an Nginx/PHP-FPM server, the log entry is always in the format:
<TIMESTAMP> 506#0: *66699 FastCGI sent in stderr: "PHP message: <MESSAGE FROM PHP SCRIPT>" while reading response header from upstream, client: xx.xx.xx.xx, server: <SERVER>, request: "<HTTP CALL>", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "<HOST>", referrer: "<REFERRAL>"
Is there any way to make this cleaner so that there isn't so much excessive text like the way Apache logs errors? For example:
<TIMESTAMP>, <IP> <PHP MESSAGE>, <REFERRAL>

Categories