Questions tagged [reactphp]

1

votes
1

answer
404

Views

ReactPHP - Working with Laravel and Timers

So here is a very interesting problem I am having. I am dead set on trying to figure out how to integrate a websocket client into Laravel 5.5 to allow communication over a websocket between my application and a Discord Gateway. I spooled up a new Laravel app and required this library, via composer,...
Dave
1

votes
1

answer
53

Views

How async request handling in real cases works?

Most tutorials I have seen for Node JS/ReactPHP is more like, that you don't need to wait a 5 seconds timer to echo something. EventLoop can handle that later. Like This Example Below (Note this is non-language dependent): timer(run 5 seconds later){ print 'username'; } print ', another text'; // no...
re2t1e75
1

votes
0

answer
47

Views

ReactPHP How to access this (green boxed) data?

Just some noob-ish question from me, How to get this (green boxed) data from This Image (sorry i can't post image yet on stackoverflow because my reputation is still under 10. This is my first question on SO.) I use laravel 5.7 and this packages: https://github.com/clue/reactphp-buzz https://github....
esyede
1

votes
1

answer
1.6k

Views

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 rejected. This is to create a driver for RedBeanPHP using R...
Phillip Whelan
1

votes
1

answer
872

Views

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 parameter must be greater than 0 in C :\wamp\www\ven...
Min Wang
1

votes
1

answer
510

Views

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
marcosh
1

votes
1

answer
119

Views

ReactPHP libevent and socket_pair throws error

I have a problem then I use ReactPHP event-loop with stream_socket_pair. With StreamSelect loop it works perfectly but then I try to use it with LibEvent extension I got unlimited stream of error: [warn] kevent: Bad file descriptor The minimal code to reproduce this error
Aurimas Niekis
1

votes
1

answer
357

Views

Possible to broadcast using ReactPHP?

Is it possible to broadcast or emit data over to browser and catch it with javascript to treat it accordingly, using ReactPHP without Ratchet? I have a periodicTimer on event-loop and sometimes it needs to broadcast or emit to users connected by a socket. I saw there was a class socket and in the ex...
1

votes
1

answer
408

Views

ReactPHP and Promises

I'm trying to understand the concept of Promises using ReactPHP $app = function ($request, $response) use ($redis, $config) { $promise = React\Promise\all( array( AsyncGetUser(), AsyncGetDB(), AsyncGetTemplate() ) )->then(function ($res) { $result = ParseTemplate($user, $template, $whatever); } \Rea...
Alex Boroda
1

votes
1

answer
184

Views

How to retrieve newly created entity by asynchronous command (CQRS) in same php process?

I am implementing PHP application with CQRS. Let's say I have CreateOrderCommand and when I do $command = new CreateOrderCommand(/** some data**/); $this->commandBus->handle($command); CommandBus now just pass command to proper CreateOrderCommandHandler class as easily as: abstract class SimpleComm...
Tom
1

votes
1

answer
143

Views

React PHP timeout always resolves

I was playing around with React and wanted to try to get a working timeout function. Following (sort of) the examples and Unit tests from https://github.com/reactphp/promise-timer#timeout I came up with: use React\Promise\Timer; $promise = uncertainOperation(); $loop = \React\EventLoop\Factory::crea...
Robse
1

votes
2

answer
300

Views

Cannot get ReactPHP promises to execute asynchronously

I have a PHP script that processes data downloaded from multiple REST APIs into a standardized format and builds an array or table of this data. The script currently executes everything synchronously and therefore takes too long. I have been trying to learn how to execute the function that fetches...
Viktorius
1

votes
2

answer
329

Views

Php 7.1 + Pecl-event + libevent - is hanging in weird case

Based on this answer, I've switched to pecl-event library. Now I have: [root]# php -v PHP 7.1.12 (cli) (built: Nov 22 2017 08:40:02) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologieswith Zend OPcache v7.1.12, Copyright (c) 1999-2017, by Zend...
Dmitry Pismennyy
1

votes
2

answer
167

Views

React SecureServer runs but throws SSL_ERROR_NO_CYPHER_OVERLAP in browser

We've set up a secure socket server, which was working before securing it with SecureServer. Running the php script succeeds but when trying to connect from application, the browser throws a SSL_ERROR_NO_CYPHER_OVERLAP error. Probably something is wrong in our php script. does someone know how to ta...
Brainfeeder
1

votes
1

answer
718

Views

Async PHP requests

So, I want to create an asynchronous web service in PHP. Why? Because I've a nice async front-end, but Chrome will block my requests if I have more than 6 active TCP connections. Of course I have read some similar questions like: Async requests in PHP Multiple PHP Requests Crashing Page but these do...
GuyT
17

votes
2

answer
8.6k

Views

Ratchet PHP WAMP - React / ZeroMQ - Specific user broadcast

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. Attempti...
Jimbo
2

votes
1

answer
447

Views

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 messages from 'todo' (and ack them individually) and then...
Langosh
3

votes
1

answer
300

Views

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 1337. Client is able to write data to the server. Server is a...
user1032531
2

votes
2

answer
863

Views

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(); sleep(2); $deferred->resolve(); return $deferred->promise(); } Rout...
jvrnt
4

votes
1

answer
122

Views

Docker running ReactPHP http server script - not exposing the port

I am experimenting with building lightweight api server, that needs to handle many req/sec, using the following tech: 7.1-cli-alpine (docker image) - small memory/disk footprint, no need for web server ReactPHP - low-level library for event-driven programming (perfect for non-blocking I/O ops) Here...
Latheesan
2

votes
1

answer
78

Views

Write LogFile with date on running service

I've created a service with reactphp which runs and does some stuff. It is started as a daemon so all output should be logged in a file. This log file should be named 'foo-log-file-$(date '+F')'. I want to have a single log file for each day. Problem: As mentioned the script runs as a service, wit...
alabama
2

votes
2

answer
1.4k

Views

Guzzle vs ReactPHP vs Amphp for parallel requests

What's the difference between: GuzzleHttp ReactPHP Amphp How they differ and what would be typical use case to use with?
lubosdz
3

votes
1

answer
1.4k

Views

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 (other than 'close'), the server's terminal nicely s...
mOrloff
4

votes
1

answer
4k

Views

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 implode(PHP_EOL, error_get_last()), PHP_EOL; }); $loop = React\...
swahnee
29

votes
1

answer
14.6k

Views

Is ReactPHP truly asynchronous?

I've been doing some tests on ReactPHP because it looks pretty awesome. I've tested it with the following react/socket code, for a simple socket server. $loop = React\EventLoop\Factory::create(); $socket = new React\Socket\Server($loop); $socket->on('connection', function ($conn) { echo 'New client...
Divi
3

votes
1

answer
645

Views

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 = new React\ZMQ\Context($loop); $worker = $context->g...
vicaba
6

votes
1

answer
1k

Views

Gracefully close ReactPhp app

The question is very related to Consume only N messages from RabbitMQ with react\stomp, ack them separately and then exit, but a bit more general. For example, I have a slow I/O operation: $port = 4000; $loop = React\EventLoop\Factory::create(); $socket = new React\Socket\Server($loop); $socket->on...
Alex Blex
6

votes
2

answer
399

Views

I need to implement a wait timer INSIDE of a PHP React websocket event loop (perhaps multithreading?)

I have a websocket application that I am building a game on, built on Ratchet which uses the React event loop. At the start of this script, I have already figured out how to implement a periodictimer, to send a pulse to the game every second, and then execute ticks and combat rounds. This works grea...
Lynne
7

votes
1

answer
3.2k

Views

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

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 ?
Reza Shadman
13

votes
1

answer
277

Views

Reactphp process status statistic (idle, worked, etc)

I starting using http://reactphp.org/ for handle HTTP request. I run multiple react workers that run on different ports and then use Nginx as load balancing to handle requests. Like this upstream backend { server 127.0.0.1:13300; server 127.0.0.1:13301; ..... } All works well as expected. The quest...
1

votes
1

answer
578

Views

ReactPHP/Socket server - set connection timeout

I have TCP Socket server using react\socket. Depending on received data from the client, it doing something, then it close connection with the client. The problem is i can't understand how to make connection timeout, if the server have not received any data for a period of time, how to close connect...
J_z
2

votes
1

answer
81

Views

Connecting to react server from another machine

Following the instructions at http://reactphp.org/, I created a server:
user1032531
3

votes
1

answer
197

Views

How to retrieve specific ReactPHP socket error?

The following has an on error event. How can I determine the specific error?
user1032531
7

votes
1

answer
388

Views

Why websockets stop broadcasting after some time? ( implementation uses ReactPHP, Ratchet & ZeroMQ )

I have a small websocket server, running on top of a set of libraries: ReactPHP, Ratchet and ZeroMQ, using a php-zmq wrapper. The code is basically the same as in the tutorials. The eventloop starts correctly, users are able to connect to the server, they are getting correct messages, when the other...
Finwe
2

votes
1

answer
524

Views

React warning “stream_select(): cannot represent a stream of type ZMQ_FD as a select()able descriptor”

I'm trying to use Ratchet for the first time and am following the push tutorial. I have the following code in push-server.php: namespace app\ratchet; require_once(__DIR__ . '/../common_functions.php'); // my autoloader require __DIR__ . '/../../vendor/autoload.php'; // composer autoloader use app\ra...
Nate
6

votes
1

answer
6.3k

Views

React PHP with Laravel 4

I'm using Laravel 4 and as I was going through React PHP , wandering if there is any way to use React PHP with Laravel. Is there any example to start with React PHP with Laravel ? or any suggestion to use it with Laravel ?
Chinmoy
2

votes
0

answer
882

Views

Session handling with ReactPHP

I'm planning to run my existing Zend Framework 2 application using ReactPHP and so far it's going well, but I have troubles with sessions handling. So far I'm using this ReactPHP module for ZF2 which is letting me run my project very easy. I guess that I cannot use session_* functions, because they...
5

votes
1

answer
960

Views

Ratchet PHP and long running tasks

I am using ratchet php. I am starting it like this: $loop = \React\EventLoop\Factory::create(); $webSock = new \React\Socket\Server($loop); $webSock->listen($this->port, $this->host); $webServer = new \Ratchet\Server\IoServer( new \Ratchet\Http\HttpServer( new \Ratchet\WebSocket\WsServer( new Pus...
harveyslash
4

votes
2

answer
3.8k

Views

Alternative web server for PHP: React or PHP's embedded server? [closed]

I always used Apache for my PHP projects. But now, I want to leave it, to start using one of the following options: React or PHP's built-in web server Which has more performance? In definitely, what is the best? Which is your recommendation?
2

votes
2

answer
299

Views

Detecting if React PHP client cannot connect to server

How can it be detected that a React PHP client cannot connect with a server? I was hoping for the fictional else() method that I showed at the bottom. Do I just need to wait a reasonable amount of time, and if no on data event occurs, it isn't connected.
user1032531

View additional questions