Hello,
this is the expected behavior.
The web server you wrote is an asynchronous webserver. This mean that every call you will write should not non-blocking.
The sleep method is blocking, that's why it blocks the whole process.
It's a bit disturbing when you start with it, you will have to rethink the way you program PHP to use non-blocking features.
If you need to use blocking function, dispatch these on workers with react/zmq or react/stomp
Hope it will help you
--
Romain
On Monday 15 April 2013 at 07:35,
rahe...@gmail.com wrote:
> Hi,
>
> I tested react and though its good as a webserver it still doesnt have the concurrency required.
> Here is the code I tested with :
> <?php
>
> require 'vendor/autoload.php';
>
> $app = function ($request, $response) {
> $response->writeHead(200, array('Content-Type' => 'text/plain'));
> //print_r($request->getQuery());
> $get = $request->getQuery();
>
> // If "e" is there in the query string make this sleep for a 100 seconds
> if(!empty($get['e'])){
> echo sleep(100);
> }
>
> $response->end("Hello World\n");
> };
>
> $loop = React\EventLoop\Factory::create();
> $socket = new React\Socket\Server($loop);
> $http = new React\Http\Server($socket, $loop);
>
> $http->on('request', $app);
> echo "Server running at
http://127.0.0.1:1337\n";
>
> $socket->listen(1337);
> $loop->run();
>
> ?>
> You can access
http://127.0.0.1:1337/ to see the hello world.
> Then access
http://127.0.0.1:1337/?e=1
> That particular request will sleep for 100 seconds.
> Then I access
http://127.0.0.1:1337/ again to see if it can serve the file.
> But its not serving anything as its waiting for the first request to complete. So I guess react doesnt have concurrency ?
> Please let me know if I am doing something wrong ?
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Ratchet" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
ratchet-php...@googlegroups.com (mailto:
ratchet-php...@googlegroups.com).
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>