两个不同的“发布者套接字”可以使用 zmq 在同一地址和端口上发布消息吗?

Can two different `publisher sockets` publish messages on same address and port using zmq?

我有两个不同的node.js进程(不同的发布者套接字实例)需要使用不同的主题发布消息但是相同的地址和端口使用 zmq
这样做是正确的方法还是对不同的发布者套接字实例使用不同的地址和端口总是好的? 请注意,我对不同的发布者使用不同的主题。

很遗憾,没有。

从同一地址和端口上的两个不同进程调用 Socket.Bind() 将导致 ZeroMQ "Address in Use" 异常。

Luckily!

A subscriber can connect to more than one publisher, using one connect call each time. Data will then arrive and be interleaved ("fair-queued") so that no single publisher drowns out the others.

答案是肯定的!使用 zmq.FORWARDER 设备:

http://learning-0mq-with-pyzmq.readthedocs.io/en/latest/pyzmq/devices/forwarder.html