CentOs 6, Php7.1, libevent, nginx returns 502

2019-08-28 19:25发布

I am upgrading laravel web application from php5.6 to php7.1 which leads me to upgrading libevent module. Application is async ans based on react library.

So I ended with installed: PHP 7.1.12, libevent: 2.1.8 + expressif/pecl-event-libevent. And I have stable "502 Bad Gateway" from nginx. Without libevent (ReactStreamLoop) or on PHP 5.6 + libevent:1.4 works fine. Request lands to index.php and something happens later, inside of starting application.

nginx log:

2017/11/24 10:41:24 [error] 24985#0: *7 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 14.183.16.180, server: 173.199.117.122, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "173.199.117.122"

2017/11/24 10:41:25 [error] 24985#0: *7 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 14.183.16.180, server: 173.199.117.122, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "173.199.117.122"

php-fpm log:

[24-Nov-2017 10:41:24] WARNING: [pool www] child 22300 exited on signal 11 (SIGSEGV) after 39.486978 seconds from start

[24-Nov-2017 10:41:24] NOTICE: [pool www] child 22331 started

[24-Nov-2017 10:41:25] WARNING: [pool www] child 22301 exited on signal 11 (SIGSEGV) after 40.205103 seconds from start

[24-Nov-2017 10:41:25] NOTICE: [pool www] child 22332 started

UPDATE: works if force usage ReactStreamLoop.

UPDATE: Reproduced locally on similar config. Found such example that crashes with LibEventLoop but works with StreamSelectLoop.

require_once __DIR__.'/../vendor/autoload.php';

$loop = new \React\EventLoop\LibEventLoop();
//$loop = new \React\EventLoop\StreamSelectLoop();

$config = array(
    'host'      => '127.0.0.1',
    'port'      => '3306',
    'dbname'    => 'mysql',
    'user'      => 'root',
    'passwd'    => 'root',
    'charset'   => 'utf8',
);

$client = new \React\MySQL\Connection($loop, $config);

$client->connect(function() {});

$client->query('select 8 as cnt', function () {
    echo "inside\n";
});

echo "start\n";
$loop->run();

output:

#php ./tests/test.php 
start
Segmentation fault (core dumped)

1条回答
虎瘦雄心在
2楼-- · 2019-08-28 20:18

The extension you're using is not compatible with PHP 7 and up. You have to use one of the other event loop implementations, such as the one based on stream_select() or one of the supported extensions.

See https://github.com/reactphp/event-loop/pull/62 for further information.

查看更多
登录 后发表回答