jeffbass / imagezmq

A set of Python classes that transport OpenCV images from one computer to another using PyZMQ messaging.
MIT License
1.03k stars 162 forks source link

Connection hangs if no publisher #76

Open tim-flux opened 2 years ago

tim-flux commented 2 years ago

Great Codebase, thank you so much for it. I have a question in regards to the pubsub design. If i have no publisher running the system hangs would it be better to bind the port on the hub side rather than the Senders side.

jeffbass commented 2 years ago

I'm not sure I understand what you mean by "system hangs". Perhaps you could share a specific code example? If there is no ImageSender publisher running and sending images, there is nothing for the ImageHub subscriber to process. I would expect the ImageHub to "hang" (not do anything) until the first inbound image is received.

In the typical imageZMQ PUB/SUB architecture, it is assumed that multiple ImageSenders are PUBs and there is a single ImageHub SUB receiving the images from these multiple ImageSender PUBs. The way this is done is to use socket.bind() on each ImageSender PUB and socket.connect (multiple times as needed for multiple ImageSender / publishers) on the SUB / imgageHub side. The imageZMQ PUB/SUB pattern is modeled on this PyZMQ documentation example. I'm not sure how socket.bind() could be used for ImageHub / SUB side.

ZMQ and PyZMQ are capable of many more messaging patterns than the 2 that are implemented in imageZMQ. If one of those messaging patterns would be more suitable, you might want to experiment with forking imageZMQ and using a different ZMQ messaging pattern.