You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I have a question. Can i create multiple Sender connect_to same address in 1 PC( localhost) and only 1 Hub get it?
I want to use Pub/Sub mode like this image
The text was updated successfully, but these errors were encountered:
Hi @huyker,
Yes, you can use multiple Senders to send to a single Hub using PUB/SUB. The Hub will have to subscribe to each sender with the sender's specific TCP address. The Senders (Publishers) do not need to know the address of the Hub.
For your 3 Senders (Publishers), the ImageSender instantiation code looks like this:
# Each of your 3 senders must allow subscribers from any tcp address, port 5555sender=imagezmq.ImageSender(connect_to='tcp://*:5555', REQ_REP=False) # same in all 3 Senders
Note that the above connect_to= is exactly the same on all 3 Senders. Senders in PUB/SUB mode do NOT specify the address of the Hub / Subscriber.
For the Hub (Subscriber), the Hub instantiation code needs to specify the exact TCP address of every sender. For Sender 1, this is specified in the ImageHub instantiation. For Sender 2 and Sender 3, the ImageHub.connect() method is used:
# Instantiate ImageHub and provide the first sender / publisher addressimage_hub=imagezmq.ImageHub(open_port='tcp://192.168.86.39:5555', REQ_REP=False)
# Then, use the connect() method to connect to sender / publisher 2 and 3image_hub.connect('tcp://192.168.86.38:5555') # connect to second sender / publisher address image_hub.connect('tcp://192.168.86.42:5555') # connect to third sender / publisher address
There is a pair of example programs demonstrating this in the imageZMQ examples folder:
ImageSender PUB program (this will be the same for all 3 senders) example.
ImageHub SUB program (it shows how to subscribe / connect to multiple senders) example.
The imageZMQ API has details about the connect method here. See line 72.
Let me know if this works for you or if you have any questions,
Jeff
Hello,
I have a question. Can i create multiple Sender connect_to same address in 1 PC( localhost) and only 1 Hub get it?
I want to use Pub/Sub mode like this image
The text was updated successfully, but these errors were encountered: