简体   繁体   English

ZeroMQ和PHP-FPM

[英]ZeroMQ and PHP-FPM

I just came across the problem that ZeroMQ in PHP seems to work properly when used on the command line, but not in an FPM process. 我刚刚遇到这样的问题:在命令行中使用PHP时,ZeroMQ似乎正常工作,但在FPM进程中却没有。 Did anyone else observe this behaviour? 有没有人观察到这种行为? Is there an easy solution? 有一个简单的解决方案吗? Maybe it is a matter of rights management or something? 也许这是一个权利管理问题? Unfortunately there are no error messages at all. 不幸的是,根本没有错误消息。


The server is started from the command line: 服务器从命令行启动:

$context = new ZMQContext;
$socket = new ZMQSocket($context, ZMQ::SOCKET_PULL);
$socket->bind('ipc:///tmp/test.sock');
while (true) echo $socket->recv();

Another script is located on my local webserver (nginx + php-fpm): 另一个脚本位于我的本地网络服务器上(nginx + php-fpm):

$context = new ZMQContext;
$socket = new ZMQSocket($context, ZMQ::SOCKET_PUSH);
$socket->connect('ipc:///tmp/test.sock');
$socket->send('Test Message');

If one executes this script from the command line, the message is transferred to the zmq server without problems. 如果从命令行执行此脚本,则消息将传输到zmq服务器而不会出现问题。 If I execute the script through the browser, nothing happens. 如果我通过浏览器执行脚本,则没有任何反应。

According to the zeromq bug tickets, this is a known problem, but they have no intention of fixing it: 根据zeromq bug票证,这是一个已知问题,但他们无意修复它:

https://github.com/zeromq/libzmq/issues/48 https://github.com/zeromq/libzmq/issues/48

I also tried changing permissions, as indicated on other threads (and confirmed that I am successfully creating them as 0777 when viewed in the filesystem), but no luck with zeromq: 我也试过更改权限,如其他线程所示(并确认我在文件系统中查看时成功创建了0777),但zeromq没有运气:

UNIX domain sockets not accessable across users? UNIX域套接字无法跨用户访问?

I also finally gave up and used TCP. 我终于放弃了并使用了TCP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM