问题标签 [reactphp]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
397 浏览

php - 如何使用 php 创建异步套接字服务器?

我正在尝试创建一个异步套接字服务器来处理套接字客户端,在需要时向客户端发送消息。我使用reactphp 库来实现它,但我做不到正确,我的服务器仍然被阻止。我是这个图书馆的新手,请帮忙。

0 投票
1 回答
378 浏览

php - React PHP超时总是解决

我在玩 React 并想尝试获得一个工作超时功能。遵循(某种)来自https://github.com/reactphp/promise-timer#timeout的示例和单元测试我想出了:

但是,无论我在Timer\timeout中设置的时间有多低,这总是以“完成”来解决。我错过了什么?

0 投票
2 回答
1814 浏览

php - 实时应用 Symfony - 使用什么技术?

我想知道是否有人可以向我解释如何使用 Symfony 构建实时应用程序?

我和我最好的朋友谷歌一起查看了很多文档,但我没有找到非常详细的文章。

我想要一些更面向 PHP 的东西,并看到有 ReactPHP / Ratchet 之类的技术(但我找不到足够清晰的教程将其集成到现有的 symfony 项目中)。

您对使用哪些技术以及为什么使用有任何建议?(如果你有我拿的教程链接!)

预先感谢您的回答!

0 投票
1 回答
202 浏览

symfony - 带有 symfony 图像和 css 的 Reactphp

我正在使用带有 symfony 的 reactphp 我的反应网络服务器链接是http://localserver.reactsymfony:1337/

没有任何 css 和图像文件服务。例如(http://localserver.reactsymfony:1337/bundles/calibration/css/bootstrap.min.css)它给了我 404 not found 错误。

我不知道如何摆脱这个错误。

0 投票
2 回答
260 浏览

php - Using reactive PHP in a blocking application

I'm currently working on a PHP application that will be using some websocket connections to talk to another service.

To talk to this websocket service, we are using Ratchet - which is a PHP library based on react PHP.

This piece of code needs to send and respond to a couple of requests, and after that, should return the information to the "main thread".

Example flow:

HTTP request -> controller -> Starts a service which opens a websocket client -> websocket client is talking to server -> once its done it should return the outcome to the controller code -> controller outputs to user

The issue I'm having is that I'm not familiar with Reactive PHP and am not sure how to handle this.

I've tried;

The service code would set its "response" variable to something other than null once its done. This obviously fails, because the sleep method is blocking the thread. Also without, it seems like the while loop is blocking I/O and the reactive code fails.

A solution would be to open up a new thread and run the websocket code there, but I wouldn't be happy with that.

I feel like I need to implement some sort of "watcher" around the websocket process, but I'm not sure how to do that.

Our Websocket service client code looks like this;

Running the code like this also does not work;

because the "test" echo comes before I even get a response from the websocket server.

Please, enlighten me! I'm not sure what to search for.

0 投票
2 回答
3661 浏览

php - 如何在 ratchetphp 上自动重新连接客户端?

我正在使用 rachetphp 为 api 服务器创建客户端。但是我有一个问题,当我的连接关闭时,无论什么原因,我都无法自动重新连接。

这里是我使用的库:https ://github.com/ratchetphp/Pawl

我想在连接关闭后每隔几秒重新连接一次。有任何想法吗?

0 投票
2 回答
825 浏览

php - ZeroMQ + ReactPHP:多个生产者(推)和多个消费者(拉)

我正在使用reactphp/zmq

我怎样才能在多个拉动工人中拥有多个推动工人,这可能吗?

A only 可以有多拉和单推,如 README 的示例:

或单拉多推:

当我尝试将两者都设置为connect pulls 时不会收到消息

否则,尝试使用它启动多个进程bind会抛出:


我应该有一个中间件吗?

0 投票
2 回答
525 浏览

php - 检测 React PHP 客户端是否无法连接到服务器

如何检测到 React PHP 客户端无法与服务器连接?else()我希望我在底部显示的虚构方法。我是否只需要等待一段合理的时间,如果没有on data事件发生,它就没有连接。

0 投票
1 回答
224 浏览

php - ReactPHP - 使用“NodeJS”在“pm2”等服务器上保持在线 - 进程管理器

我一直在研究“ReactPHP”,但是如果出现错误,我不明白如何让它在服务器上运行。我搜索发现“NodeJS”有“pm2”用于在服务器上保持在线或者如果出现错误它会重新启动,我想知道是否有类似PM2的程序用于“ReactPHP”?以及如何实施?

谢谢。

0 投票
1 回答
883 浏览

php - TCP 套接字是持久的吗?

我在 Raspberry Pi3 上运行的 c++ 客户端和在 Centos7 上使用 Php7 运行的 ReactPHP 服务器之间遇到套接字中断。请参阅以下内容:

  1. 客户端使用 TLS over TCP 在端口 1337 上创建到服务器的套接字连接。
  2. 客户端能够将数据写入服务器。
  3. 服务器能够将数据写入客户端。
  4. Tshark 在两台机器上都运行,过滤器只针对端口 1337,并看到了这个初始通信。
  5. 在接下来的一个小时内没有发生通信,两台机器上的 Tshark 都确认没有发生通信。
  6. 客户端或服务器都没有收到关闭的连接,并认为连接仍然打开。
  7. 然后服务器尝试向客户端写入更多数据,Tshark 看到服务器线路上的传输,但 Tshark 没有看到客户端线路上的传输,显然客户端没有响应。
  8. 如果客户端守护程序随后关闭,则服务器会感知到连接已关闭。
  9. 如果随后关闭服务器守护程序而不是客户端守护程序,则客户端不会感知到连接已关闭。

php.ini 将 default_socket_timeout 显示为 60 秒,并且更改该值似乎没有任何影响。

是什么导致了这种情况,我该如何预防?

谢谢