[zeromq-dev] python and pub/sub, don't see packets going out

Aaron Sokoloski asokoloski at gmail.com
Wed Mar 2 02:31:16 CET 2016


Hi Jerry,

It looks like you're forgetting to subscribe on the client end.  The
publisher won't send anything because the client never told it that it
wanted to subscribe.  You can just subscribe to "" to get all messages.

Cheers,
Aaron

On 1 March 2016 at 19:18, Jerry Scharf <scharf at lagunawayconsulting.com>
wrote:

> Hi,
>
> I have req/rep working fine now. There is one deviation from the pyzmq
> documentation. The documentation says that you use socket.send with a
> string, but the code errors out and says use send_string instead. I
> don't know if this is a version problem in the zmq I built, but I just
> did pip install pyzmq.
>
> Now I am trying to make pub/sub work and am stuck again. Here's my
> trivial server:
>
> import zmq
>
> zc = zmq.Context()
> pubsock = zc.socket(zmq.PUB)
> pubsock.bind("tcp://*:12345")
>
> for i in range(10):
>      msg = "topic sending message {}".format(i)
>      pubsock.send_string(msg)
>
> and here's my trivial client:
> import zmq
>
> zc = zmq.Context()
> subsock = zc.socket(zmq.SUB)
> subsock.connect("tcp://localhost:12345")
>
> for i in range(10):
>      message = subsock.recv_string()
>      print("{}\n".format(message))
>
> print("got 10\n")
>
>
> The client sits happily waiting for the packets that never come. When I
> watch this with tcpdump, I see a bunch of packets go back and forth
> during the connect but no packets come out when I do the send_string.
> The same symptoms are true both on the raspberry pi and a ubuntu machine.
>
> Any clue what is going on?
>
> jerry
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20160301/c2f1708e/attachment.htm>


More information about the zeromq-dev mailing list