[zeromq-dev] Sub loses messages
Andriy Zakharchuk
andriyzakharchuk402 at gmail.com
Thu Jan 15 12:13:22 CET 2015
Hi all,
I use ZeroMQ 4.1.0. Php 5.4.3. I use pattern synchronized publisher
subscriber. Everything is good If I have one concurrent user. But if I run
apache benchmark (e.g. ab -c 2 -n 10 <url>), I receive error "The timeout
specified has expired" after first request.
This is my publisher:
$context = new ZMQContext();
// Socket to talk to clients
$publisher = $context->getSocket(ZMQ::SOCKET_PUB, 'server');
$publisher->connect("tcp://127.0.0.1:5561");
// Socket to receive signals
$syncservice = $context->getSocket(ZMQ::SOCKET_REQ);
$syncservice->connect("tcp://127.0.0.1:5562");
// - send synchronization reply
$syncservice->send("");
// Get synchronization from subscribers
$string = $syncservice->recv();
$message = strlen($message) . $message;
$publisher->send($message);
// close socket connections
$syncservice->disconnect("tcp://127.0.0.1:5562");
$publisher->disconnect("tcp://127.0.0.1:5561");
This is my subscriber:
$context = new ZMQContext();
// First, connect our subscriber socket
$subscriber = $context->getSocket(ZMQ::SOCKET_SUB);
$subscriber->bind("tcp://127.0.0.1:5561");
$subscriber->setSockOpt(ZMQ::SOCKOPT_SUBSCRIBE, "");
// Second, synchronize with publisher
$syncclient = $context->getSocket(ZMQ::SOCKET_REP);
$syncclient->bind("tcp://127.0.0.1:5562");
// - wait for synchronization reply
$string = $syncclient->recv();
// - send a synchronization request
$syncclient->send("");
// receives real data
$message = $subscriber->recv();
// close socket connections
$syncclient->unbind("tcp://127.0.0.1:5562");
$subscriber->unbind("tcp://127.0.0.1:5561");
Thanks, Andriy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20150115/bf6283cb/attachment.htm>
More information about the zeromq-dev
mailing list