Skip to content
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

PHP-FPM compatibility #77

Open
iorsa opened this issue Feb 3, 2020 · 4 comments
Open

PHP-FPM compatibility #77

iorsa opened this issue Feb 3, 2020 · 4 comments

Comments

@iorsa
Copy link

iorsa commented Feb 3, 2020

Hi,

I'm stacked at situation where I can't use this beautiful library.

I have PHP 7.0.32 with php-fpm enabled.
Here is additional information about extensions directly from phpinfo:

//
PHP libuv Extension
libuv Support enabled
Version 0.2.2
libuv Version 1.26

//
eio
eio support enabled
Debug support disabled
Version 2.0.4

//
event
Event support enabled
Sockets support enabled
Debug support disabled
Extra functionality support including HTTP, DNS, and RPC enabled
OpenSSL support enabled
Thread safety support disabled
Extension version 2.4.2
libevent2 headers version 2.0.19-stable

//
libevent
libevent support enabled
extension version 0.2.0-dev
Revision $Revision$
libevent version 2.1.8-stable

Here is the code I'm using:

<?php

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

$loop = \React\EventLoop\Factory::create();

// I tried various loop implementations, but all next produce 'Timed out after 15 seconds' error message
//
//$loop = new \React\EventLoop\ExtUvLoop();
//$loop = new \React\EventLoop\StreamSelectLoop();
//$loop = new \React\EventLoop\ExtEventLoop();

// This loop implementations doesn't work at all
//
//$loop = new \React\EventLoop\ExtEvLoop();// Class 'EvLoop' not found
//$loop = new \React\EventLoop\ExtLibevLoop();// Fatal error: Uncaught BadMethodCallException: Cannot create ExtLibevLoop, ext-libev extension missing
//$loop = new \React\EventLoop\ExtLibeventLoop();// 502

// With default adapter it hangs forever
//
//$filesystem = \React\Filesystem\Filesystem::create($loop);

// With this adapter it produce 'Timed out after 15 seconds' error message
$adapter = new \React\Filesystem\ChildProcess\Adapter($loop);
$filesystem = \React\Filesystem\Filesystem::createFromAdapter($adapter);

echo 'Using ', get_class($filesystem->getAdapter()), '<br/>';

$filename = __DIR__ . '/test_putcontents.txt';

$contents = 'contents';

$filesystem->file($filename)
->putContents($contents)
->then(
	function () use ($filename)
	{
		echo "filename {$filename} written<br/>";
	},
	function (Exception $e)
	{
		echo $e->getMessage() . '<br/>';
		echo $e->getTraceAsString() . '<br/>';
	}
)
->done(
	function($someValue)
	{
		$error_or_not = "error_or_not resolved with someValue: {$someValue}<br/>";
		
		echo $error_or_not."<br/>";
	},
	function($someReason) use ($filename)
	{
		$error_or_not = "error_or_not rejected with someReason: {$someReason}<br/>";
		
		echo $error_or_not."<br/>";
	}
);

$loop->run();

?>

Here are my results with various loop implementations

Using React\Filesystem\ChildProcess\Adapter
Timed out after 15 seconds
#0 /var/www/user/data/www/vendor/react/event-loop/src/ExtUvLoop.php(119): React\Promise\Timer\{closure}(Object(React\EventLoop\Timer\Timer)) #1 [internal function]: React\EventLoop\ExtUvLoop->React\EventLoop\{closure}(Object(UVTimer)) #2 /var/www/user/data/www/vendor/react/event-loop/src/ExtUvLoop.php(230): uv_run(Object(UVLoop), 1) #3 /var/www/user/data/www/test_write_file_new.php(88): React\EventLoop\ExtUvLoop->run() #4 {main}
error_or_not resolved with someValue:
Using React\Filesystem\ChildProcess\Adapter
Timed out after 15 seconds
#0 /var/www/user/data/www/vendor/react/event-loop/src/Timer/Timers.php(96): React\Promise\Timer\{closure}(Object(React\EventLoop\Timer\Timer)) #1 /var/www/user/data/www/vendor/react/event-loop/src/StreamSelectLoop.php(184): React\EventLoop\Timer\Timers->tick() #2 /var/www/user/data/www/test_write_file_new.php(88): React\EventLoop\StreamSelectLoop->run() #3 {main}
error_or_not resolved with someValue:
Using React\Filesystem\ChildProcess\Adapter
Timed out after 15 seconds
#0 /var/www/user/data/www/vendor/react/event-loop/src/ExtEventLoop.php(243): React\Promise\Timer\{closure}(Object(React\EventLoop\Timer\Timer)) #1 [internal function]: React\EventLoop\ExtEventLoop->React\EventLoop\{closure}(-1, 1, Object(React\EventLoop\Timer\Timer)) #2 /var/www/user/data/www/vendor/react/event-loop/src/ExtEventLoop.php(204): EventBase->loop(1) #3 /var/www/user/data/www/test_write_file_new.php(92): React\EventLoop\ExtEventLoop->run() #4 {main}
error_or_not resolved with someValue:

I'm using next versions of libraries:

  • react/event-loop v1.1.0 a0ecac955c67b57c40fe4a1b88a7cca1b58c982d
  • react/filesystem v0.1.2 766cdef

Do you need any additional information?

@WyriHaximus
Copy link
Member

You mentioned PHP-FPM, does this mean what you're trying to do runs in PHP-FPM?

@iorsa
Copy link
Author

iorsa commented Feb 3, 2020

Yes.

@WyriHaximus
Copy link
Member

Hmm ok, just FYI we don't test anything in PHP-FPM, it shouldn't matter tho.

@iorsa
Copy link
Author

iorsa commented Feb 4, 2020

Well, I should, first of all, check the same code with PHP in CLI mode, to exclude php-fpm compatibility.
I've checked it recently and can confirm that in CLI it works as expected with each adapter (ChildProcess, UV and EIO), so the issue is related to php-fpm compatibility.

Though, I'm using php-fpm with other reactphp libraries (event-loop, promises, mysql, http-client/buzz-browser) almost everyday over 6 months and can't remember similar problems, so it may depend only on this (filesystem) library.

@iorsa iorsa changed the title Something wrong in my setup or filesystem (adapters or libraries versions compatibility) doesn't work as expected? PHP-FPM compatibility Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants