So I am using the python bindings for ZeroMQ in an attempt to send messages to several raspberry pis on a network for an art project. The issue is that I am not receiving any messages on the raspberry pi. To make matters worse, I can:
- Publish messages from the raspberry pi and receive them on my laptop(osx)
- A REQ/REP model works in both directions (osx -> RPI and RPI -> osx)
I was thinking that it has something to do with the firewall on either device, which I disabled on both. No luck.
Anyone have any ideas? Here is my code:
import time import zmq def main(): port = 5563 # Prepare our context and publisher context = zmq.Context() publisher = context.socket(zmq.PUB) publisher.bind("tcp://*:" + str(port)) while True: # Write two messages, each with an envelope and content publisher.send_multipart([b"A", b"We don't want to see this"]) publisher.send_multipart([b"B", b"We would like to see this"]) time.sleep(1) # We never get here but clean up anyhow publisher.close() context.term() if __name__ == "__main__": main()
import zmq import sys def main(): ip = sys.argv port = 5563 string = "tcp://" + ip + ":" + str(port) # Prepare our context and publisher context = zmq.Context() subscriber = context.socket(zmq.SUB) subscriber.connect(string) subscriber.setsockopt(zmq.SUBSCRIBE, b"B") while True: # Read envelope with address [address, contents] = subscriber.recv_multipart() print("[%s] %s" % (address, contents)) # We never get here but clean up anyhow subscriber.close() context.term() if __name__ == "__main__": main()