I want to use the ZeroMQ publisher / subscriber to send data from my web application to multiple servers.
I am using Apache and PHP for a web application, my php script works as follows:
$context = new ZMQContext();
$publisher = $context->getSocket(ZMQ::SOCKET_PUB);
$publisher->bind("tcp://*:5556");
$publisher->send("test");
$publisher->send("test");
$publisher->send("test");
$publisher->send("test");
$publisher->send("test");
For testing, I adapted the subscriber from the documentation in python:
import sys
import zmq
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.connect ("tcp://localhost:5556")
socket.setsockopt(zmq.SUBSCRIBE, "")
print "Waiting..."
for update_nbr in range (5):
string = socket.recv()
print string
All this works when I run the php script from the command line, but it doesnโt work through Apache (when the script is executed through a web browser).
Is there something I have to do for my Apache configuration to get it working?
thank
Alexander
source
share