0

Does Publish-Subscribe method work if:

  1. publisher and subscribers are in different networks (I've checked once - it works)
  2. subscribers are behind NAT\firewall

In both cases packet routing works correctly.

As I understand PUB\SUB uses the same TCP transport, so if PUB\SUB doesn't work so standard windows winsock doesn't work too? Is PUB\SUB proxy (like that http://zguide.zeromq.org/page:all#toc34) needed if packet routing mechanism is undefined only?

4

1 に答える 1

0

I've found some code uses PUB\SUB model and works with NAT here http://grokbase.com/t/zeromq/zeromq-dev/112q9934vg/nat-firewall-pub-sub-traversal:

Publisher that connects, rather than binds:

import zmq
ctxt = zmq.Context()
pub = ctxt.socket(zmq.PUB)
pub.connect("tcp://127.0.0.1:2000")
while 1:
pub.send(os.urandom(5))

Subscriber that binds, rather than connects:

import zmq
ctxt = zmq.Context()
sub = ctxt.socket(zmq.SUB)
sub.bind("tcp://127.0.0.1:2000")
while 1:
sub.rcv()
于 2012-11-04T11:49:26.290 に答える