[zeromq-dev] simple publish subscribe not working with zeromq

Karthik Sharma karthik.sharma at gmail.com
Sun Oct 12 01:16:08 CEST 2014


I want to establish publish subscribe communication between to machines.The
two machines that I have are
`ryu-primary` and `ryu-secondary`

The steps I follow in each of the machines are as follows.In the
initializer for `ryu-primary` (IP address is 192.168.241.131)

     self.context = zmq.Context()
     self.sub_socket = self.context.socket(zmq.SUB)
     self.pub_socket = self.context.socket(zmq.PUB)
     self.pub_port = 5566
     self.sub_port = 5566


    def establish_zmq_connection(self):
        # Socket to talk to server
        print "Connection to ryu-secondary..."
        self.sub_socket.connect ("tcp://192.168.241.132:%s" % self.sub_port)

    def listen_zmq_connection(self):
        print('Listen to zmq connection')
        self.pub_socket.bind("tcp://*:%s" % self.pub_port)

    def recieve_messages(self):
        while True:
            try:
                string = self.sub_socket.recv(flags=zmq.NOBLOCK)
                print('flow mod messages recieved {}'.format(string))
                return string
            except zmq.ZMQError:
                break

    def push_messages(self,msg):
        self.pub_socket.send("%s" % (msg))


>From ryu-secondary (IP address - 192.168.241.132)

In the initializer

        self.context = zmq.Context()
        self.sub_socket = self.context.socket(zmq.SUB)
        self.pub_socket = self.context.socket(zmq.PUB)
        self.pub_port = 5566
        self.sub_port = 5566


    def establish_zmq_connection(self):
         # Socket to talk to server
         print "Connection to ryu-secondary..."
         self.sub_socket.connect ("tcp://192.168.241.131:%s" %
self.sub_port)

    def listen_zmq_connection(self):
         print('Listen to zmq connection')
         self.pub_socket.bind("tcp://*:%s" % self.pub_port)

    def recieve_messages(self):
        while True:
                try:
                         string = self.sub_socket.recv(flags=zmq.NOBLOCK)
                         print('flow mod messages recieved
{}'.format(string))
                         return string
                except zmq.ZMQError:
                        break

    def push_messages(self,msg):
         print('pushing message to publish socket')
         self.pub_socket.send("%s" % (msg))


These are the functions that I have.

I am calling
establish_zmq_connections()
push_messages()
from `ryu-secondary`,

But I am not recieving those messages when I am calling
listen_zmq_connection()
recieve_messages()
from `ryu-primary`.

Can someone point out to me what I am doing wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20141012/bfd9018a/attachment.htm>


More information about the zeromq-dev mailing list