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
1
vote
1 answer

PHP - client socket connections

I am trying to create a set of websocket clients with the following code: $server = stream_socket_server("tcp://127.0.0.1:8080"); for ($i = 1; $i <= 50; $i++) { var_dump($i); stream_socket_client("tcp://127.0.0.1:8080"); } The first 35, or…
marcosh
  • 8,780
  • 5
  • 44
  • 74
1
vote
1 answer

Maximum interval on react loop->addPeriodicTimer is 2147 seconds

I'm running a timer using react\eventloop on my ratchet wamp app. I would like to have it run hourly at 3600 seconds, but for some reason if I set the interval higher than 2147 seconds I get this warning: Warning: stream_select(): The microseconds…
Bruce Wang
  • 13
  • 4
1
vote
2 answers

Using Reactphp for sockets in PHP, port stops listening

I'm developing an iOS app that has a chat system included (using these instructions). The api runs on a LAMP server, so I used ReactPhp instead of Twisted for python as socket handler to communicate between client/server and server/client. This is…
Andres SK
  • 10,779
  • 25
  • 90
  • 152
1
vote
1 answer

ZMQ REP REQ - Send Receive not working

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 =…
Alias
  • 2,983
  • 7
  • 39
  • 62
1
vote
1 answer

React/ZMQ: REQ REP only working once

I'm trying to get a request to my server via a websocket, and return a reply from the server. This is "sort of" working, however I can only do this once, any extra requests just hang somewhere. Server Bind: $pull =…
Alias
  • 2,983
  • 7
  • 39
  • 62
1
vote
2 answers

Return synchronously when a React/Promise is resolved

I need to return from a function call once a React/Promise has been resolved. The basic idea is to fake a synchronous call from an ansynchronous one. This means that the outer function must return a value once a promise has been resolved or…
Phillip Whelan
  • 1,697
  • 2
  • 17
  • 28
0
votes
1 answer

Async php http request becomes sync when using generators

I'm doing POC implementation of async http requests in PHP. The symfony http client works well when we retrieve response data following way: $response1 = $httpClient->request('GET', 'https://127.0.0.1:8000/service/a'); $response2 =…
rela589n
  • 817
  • 1
  • 9
  • 19
0
votes
1 answer

Interactive console command in symfony (PHP)

There are console programs, like an editor (say: nano for example) or like a system monitor (say: htop) where you can "navigate" with arrows and freely interact with the content. In this example, for example I have executed htop and while it's…
Xavi Montero
  • 9,239
  • 7
  • 57
  • 79
0
votes
1 answer

Export constant in react js whom data is comming from php file

I am using Php with react js ,there is constant declared in react js constant file that is used all over the application ,initially it was hardcoded in react js like Export const thumburl="www.example.com"; and its imported in almost every part of…
0
votes
1 answer

multiple asterisk ami connections with pami and react-php

I'm using PAMI with react-php and ratchet to connect with asterisk ami, I have 3 freepbx servers and want to connect with all of them in one dashboard and receive all the events from all the freepbx servers. Here is the code that I wrote in…
abdullah
  • 3
  • 1
0
votes
1 answer

How to chain multiple exception types in a promise in the ReactPhp Browser?

In ReactPhp, when using the Browser class, we do requests like this: $browser ->post( $uri, $headers, $body ) ->then ( function (Psr\Http\Message\ResponseInterface $response) { var_dump((string)$response->getBody()); }, …
Xavi Montero
  • 9,239
  • 7
  • 57
  • 79
0
votes
1 answer

Make ReactPhp to return "202 Accepted" and continue processing after the response has been sent

I'm willing to create a handler on ReactPHP that is able to return a "202 Accepted" immediately after the request has been made, but keeps doing things on the background. For this example, no matter if it's 202 or its merely 200. The problem is to…
Xavi Montero
  • 9,239
  • 7
  • 57
  • 79
0
votes
2 answers

Why can't I get response from my Docker/ReactPHP app outside the container?

I have faced with the problem! Can't get the response from browser or postman in my Docker/ReactPHP app. This is my code: docker-compose.yaml version: '3.8' services: react_php_service2: container_name: react_php_service2 build: …
0
votes
2 answers

ReactPHP Socket Client Connection Timeout

We're using ReactPHP to establish a websocket connection and listen for some data. It works great as long as the websocket server is up and running. If it can't make the websocket connection, I need it to retry after a few seconds, but can't get…
Bill Kervaski
  • 542
  • 6
  • 17
0
votes
1 answer

Do periodic job in React Socket Client

I want to do periodic job(check row in DB) inside socket client I tried to do like in this issue https://github.com/reactphp/socket/issues/167 My code $loop = \React\EventLoop\Loop::get(); $connector = new…
Alma Z
  • 244
  • 2
  • 10