reactphp

How React PHP handles async non-blocking I/O?

时光怂恿深爱的人放手 提交于 2021-02-07 06:38:54
问题 How React PHP handles async non-blocking I/O ? Nodejs uses its event queue which handles I/O on different threads. It uses libuv for this. As in PHP there isn't something like that, How React handles non-blocking I/O process on a single thread ? 回答1: React PHP provides the primary event loop of the application; you are still required to write your code in a non-blocking way since it is all on one thread. The possible solutions to this all revolve around using php differently than I am sure

PHP read data from raw tcp socket and send them through WebSocket Client using 2 React Connector

早过忘川 提交于 2020-08-10 19:13:10
问题 Here what i'm trying to do : (Socket Server:9006) <- (Websocket Client) -> (:8080 Websocket Server) I want to read data from Socket Server, edit some stuff and then send to Websocket Server. I must be able to read data coming from Websocker Server in the same time I managed to connect to both Servers using 1 React Connector for Socket Server, and 1 Ratchet Connector for WebSocket Server : $loop = React\EventLoop\Factory::create(); $connector = new React\Socket\Connector($loop); $connector-

Consume only N messages from RabbitMQ with react\stomp, ack them separately and then exit

怎甘沉沦 提交于 2019-12-24 03:25:09
问题 I am using RabbitMQ with PHP react\stomp. I have two queues - one is "todo" other is "done". Consumer reads from "todo", do its work, ACKs the message, then publishes it to the "done" queue. Is there any way of ensuring that I consume only N messages from "todo" (and ack them individually) and then quit? The main reason for that is we dont want to have long running consumers and we want to restart them after N messages. 回答1: You can set a prefetch count for a destination: The prefetch count

React PHP get POST data

*爱你&永不变心* 提交于 2019-12-22 08:36:37
问题 I'm trying to run a simple Web app over a ReactPHP Web server, but I can't figure out where to get POST data coming from an HTML form. The server is defined as: include 'vendor/autoload.php'; register_shutdown_function(function() { echo implode(PHP_EOL, error_get_last()), PHP_EOL; }); $loop = React\EventLoop\Factory::create(); $socket = new React\Socket\Server($loop); $http = new React\Http\Server($socket); $http->on('request', function(React\Http\Request $request, React\Http\Response

Ratchet PHP WAMP - React / ZeroMQ - Specific user broadcast

我只是一个虾纸丫 提交于 2019-12-20 10:10:41
问题 Note : This is not the same as this question which utilises MessageComponentInterface . I am using WampServerInterface instead, so this question pertains to that part specifically. I need an answer with code examples and an explanation, as I can see this being helpful to others in the future. Attempting looped pushes for individual users I'm using the WAMP part of Ratchet and ZeroMQ, and I currently have a working version of the push integration tutorial. I'm attempting to perform the

Cakephp 3: React/zmq library namespace

流过昼夜 提交于 2019-12-12 04:25:50
问题 I am working on on the basic tutorial on using ratchet mentioned here http://socketo.me/docs/push. I have created a test setup for the tutorial that works flawlessly. However, when I am trying to integrate the setup with CakePHP 3 I am running into problems. The ratchet and ZMQ servers are independent just the way mentioned in the tutorial. Only the following piece of code needs to move into CakePHP 3 controllers: $context = new ZMQContext(); $socket = $context->getSocket(ZMQ::SOCKET_PUSH,

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

喜欢而已 提交于 2019-12-11 17:46:12
问题 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]

ZMQ REP REQ - Send Receive not working

别等时光非礼了梦想. 提交于 2019-12-10 12:28:21
问题 I have my websocket server up and running, and for my own use I want to get back a list of the connected when I execute a static PHP script. My PHP script pull.php : $context = new ZMQContext(); $socket = $context->getSocket(ZMQ::SOCKET_REQ); $socket->connect("tcp://localhost:5552"); $socket->send('data'); $test = $socket->recv(); var_dump($test); Then on my server script: <?php require './vendor/autoload.php'; $loop = React\EventLoop\Factory::create(); $pusher = new MyApp\Pusher; $context =

Guzzle pool in PHP application

南楼画角 提交于 2019-12-07 17:03:47
问题 I am trying to use Guzzle pool in PHP. But I am having difficulty in dealing with ASYNC request. Below is the code snippet. $client = new \GuzzleHttp\Client(); function test() { $client = new \GuzzleHttp\Client(); $request = $client->createRequest('GET', 'http://l/?n=0', ['future' => true]); $client->send($request)->then(function ($response) { //echo 'Got a response! ' . $response; return "\n".$response->getBody(); }); } $res = test(); var_dump($res); // echoes null - I know why it does so

Guzzle pool in PHP application

陌路散爱 提交于 2019-12-06 00:04:59
I am trying to use Guzzle pool in PHP. But I am having difficulty in dealing with ASYNC request. Below is the code snippet. $client = new \GuzzleHttp\Client(); function test() { $client = new \GuzzleHttp\Client(); $request = $client->createRequest('GET', 'http://l/?n=0', ['future' => true]); $client->send($request)->then(function ($response) { //echo 'Got a response! ' . $response; return "\n".$response->getBody(); }); } $res = test(); var_dump($res); // echoes null - I know why it does so but how to resolve the issue. Does anybody how can I make function wait and get the correct result. If