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

Jerry Scharf scharf at lagunawayconsulting.com
Wed Mar 2 02:18:58 CET 2016


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)

for i in range(10):
     msg = "topic sending message {}".format(i)

and here's my trivial client:
import zmq

zc = zmq.Context()
subsock = zc.socket(zmq.SUB)

for i in range(10):
     message = subsock.recv_string()

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?


More information about the zeromq-dev mailing list