ZeroMQ PubSub not working w\ Pyzmq

Viewed 3259

There is probably something very small that I am missing but I am unable to get a simple pub-sub example working in Python using the official Pyzmq package (https://github.com/zeromq/pyzmq).

I am using the latest ZeroMQ stable release 4.0.3 and am able to get a simple example working pretty easily in c. I've tried on both a Mac and Ubuntu machine. I look forward to any input on this;)

Here's my code:

sub.py

import zmq

ctx = zmq.Context()
s = ctx.socket(zmq.SUB)
s.connect("tcp://127.0.0.1:5567")
s.setsockopt(zmq.SUBSCRIBE,'')

while True:
    print 'waiting...'
    msg = s.recv()
    print 'received:', msg

pub.py

import zmq

ctx = zmq.Context()
s = ctx.socket(zmq.PUB)
s.bind("tcp://*:5567")

for i in range(100):
    s.send("test")
1 Answers
Related