Questions tagged [reactphp]

React is a low-level library for event-driven programming in PHP.

Event-driven, non-blocking I/O with PHP. http://reactphp.org/ React is a low-level library for event-driven programming in PHP. At its core is an event loop, on top of which it provides low-level utilities, such as: Streams abstraction, async dns resolver, network client/server, http client/server, interaction with processes. Third-party libraries can use these components to create async network clients/servers and more.

The event loop is based on the reactor pattern (hence the name) and strongly inspired by libraries such as EventMachine (Ruby), Twisted (Python) and Node.js (V8).

172 questions
4
votes
1 answer

ReactPHP blocking inside a loop

I am trying to achieve a parallel execution of my workers and I'm using ReactPHP to help me. https://github.com/reactphp/react But I'm not getting behaviour that I'm expecting to get. Scenario: I have three…
madeye
  • 1,398
  • 3
  • 15
  • 33
4
votes
1 answer

How to talk between HTTP request & cli class objects

I have a application running that's listing to HTTP request. Each request is passed to single page where a framework object $app is instantiated and this takes care of routing / controller / model etc. Now i have a another class whose object is…
kishanio
  • 6,979
  • 8
  • 25
  • 33
4
votes
2 answers

reactPHP promises executed synchoniously

I'm trying to implement js-like promises with reactPHP. But for some reason methods executed synchronously, the end_at printed only after the promise is resolved. Code: function iterate() { $deferred = new \React\Promise\Deferred(); …
jvrnt
  • 635
  • 1
  • 6
  • 20
4
votes
1 answer

React PHP get POST data

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…
swahnee
  • 2,661
  • 2
  • 24
  • 34
4
votes
2 answers

What does $loop do in this code sample?

Phil Sturgeon wrote this article about benchmarking. What I am concerned with is this technology called ReactPHP. I have been to their GitHub, but still cannot wrap my mind around it without an example. Thankfully, I can use Phil's repo. At line…
Kim Stacks
  • 10,202
  • 35
  • 151
  • 282
3
votes
1 answer

Unable to do non blocking I/O in React PHP

I am trying to insert a record inside database coming to a react socket server. I am lost on how to do my operation in a non blocking way $loop = Factory::create(); $server = new Server('127.0.0.1:4040', $loop); $database = new…
Raheel
  • 8,716
  • 9
  • 60
  • 102
3
votes
1 answer

Are TCP sockets persistent?

I am experiencing socket disruption between a c++ client operating on a Raspberry Pi3 and a ReactPHP server operating on Centos7 with Php7. Please see the following: Client creates a socket connection to server using TLS over TCP on port…
user1032531
  • 24,767
  • 68
  • 217
  • 387
3
votes
2 answers

How to reconnect a client automatically on ratchetphp?

I'm using rachetphp to create a client for an api server. But i have a problem, when my connection close, whatever the reason, i can't reconnect automatically. here the lib i use : https://github.com/ratchetphp/Pawl
LordSoldier
  • 33
  • 1
  • 4
3
votes
1 answer

How to retrieve specific ReactPHP socket error?

The following has an on error event. How can I determine the specific error? on('connection', function (\React\Socket\ConnectionInterface $stream){ …
user1032531
  • 24,767
  • 68
  • 217
  • 387
3
votes
0 answers

ReactPHP and EOT

When I close a terminal which is connected to a reactPHP socket I get many data events where the data consists of EOT signs (hex 04): event 1: 04040404 event 2: 04040404040404040404040404040404040404 event 3: 0404040404040404 event 4:…
TiMESPLiNTER
  • 5,741
  • 2
  • 28
  • 64
3
votes
1 answer

React ZMQ, Router to Dealer, not working. ZMQ 4.0.5

I want to do an asynchronous router to dealer messaging with React but it isn't working. The code in http://zguide.zeromq.org/php:rtdealer is working, but I can't identify what I'm doing different. I'm using libzmq 4.0.5 Here is my code: $context =…
vicaba
  • 2,836
  • 1
  • 27
  • 45
3
votes
1 answer

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

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…
Langosh
  • 31
  • 2
3
votes
2 answers

Best Practice for Multiple Subscribe Methods in React / Ratchet / ZMQ

I try to build a little realtime websocket use-case, where users can login and see all other users logged in, get notified when a new user signs in or an existing user logs out. For this scenario i use the ZMQ PUSH Socket in my UserController when…
alabama
  • 413
  • 7
  • 19
3
votes
2 answers

Guzzle pool in PHP application

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(); …
nicholasnet
  • 2,117
  • 2
  • 24
  • 46
3
votes
1 answer

ReactPHP Socket Server: What triggers the write (to client)?

When trying to write to the client, the message is getting buffered, and in some cases, it's not being written at all. CURRENT STATUS: When I telnet into the server, the Server Ready: message is readily printed as expected. When I send random data…
mOrloff
  • 2,547
  • 4
  • 29
  • 48
1
2
3
11 12