[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');

//  Socket to receive signals
    $syncservice = $context->getSocket(ZMQ::SOCKET_REQ);

    //  - send synchronization reply

//  Get synchronization from subscribers
    $string = $syncservice->recv();

    $message = strlen($message) . $message;

    // close socket connections

This is my subscriber:

       $context = new ZMQContext();

        //  First, connect our subscriber socket
        $subscriber = $context->getSocket(ZMQ::SOCKET_SUB);
        $subscriber->setSockOpt(ZMQ::SOCKOPT_SUBSCRIBE, "");

         // Second, synchronize with publisher
        $syncclient = $context->getSocket(ZMQ::SOCKET_REP);

  // - wait for synchronization reply
        $string = $syncclient->recv();

        // - send a synchronization request

        // receives real data
        $message = $subscriber->recv();

        // close socket connections

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