3

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. 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):

$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. If I execute the script through the browser, nothing happens.

5
  • What are the permissions of the file /tmp/test.sock ? Jul 13, 2015 at 16:03
  • Already set to 0777...
    – blogsh
    Jul 13, 2015 at 16:12
  • Update: Just tried to use TCP now and it works. However, would be interesting to know what the IPC problem is about.
    – blogsh
    Jul 13, 2015 at 16:36
  • I have the issue only when the socket file is not writable by the apache user, a 700 owned by apache works. Do you have something that could block it ? selinux for example ? Jul 13, 2015 at 17:25
  • I'm having the same issue, although I'm using an IP address instead of a .sock file. Did you do anything specifically that helped it to work in a browser? Thanks!
    – kiradotee
    Aug 15, 2016 at 13:05

1 Answer 1

0

According to the zeromq bug tickets, this is a known problem, but they have no intention of fixing it:

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:

UNIX domain sockets not accessable across users?

I also finally gave up and used TCP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.