title: zeromq: TypeError: string indices must be integers, not str
body: <p>I want to establish publish subscribe communication between to machines.</p>
  
  <p>The two machines, that I have, are <code>ryu-primary</code> and <code>ryu-secondary</code></p>
  
  <p>The steps I follow in each of the machines are as follows.</p>
  
  <p>In the initializer for <code>ryu-primary</code> (IP address is 192.168.241.131)</p>
  
  <pre><code> 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) )
  </code></pre>
  
  <p>From ryu-secondary (IP address - 192.168.241.132)</p>
  
  <p>In the initializer </p>
  
  <pre><code>    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) )
  </code></pre>
  
  <p>These are the functions that I have.</p>
  
  <p>I am calling on <code>ryu-secondary</code>:</p>
  
  <pre><code>establish_zmq_connections()
  push_messages() 
  </code></pre>
  
  <p>On <code>ryu-primary</code>, when I call </p>
  
  <pre><code>listen_zmq_connection()
  recieve_messages() 
  </code></pre>
  
  <p><strong>after</strong> subscribing to all types of messages using <strong><code>.setsockopt( zmq.SUBSCRIBE = '')</code></strong></p>
  
  <p>However the message I am trying to send is of the following type.</p>
  
  <pre><code>msg = {'in_port':in_port,'dst':dst,'actions':actions}
  self.push_messages(msg)
  </code></pre>
  
  <p>However on the other side (<code>recieve_messages()</code> I get the following error when I do this</p>
  
  <pre><code>flow_mod = recieve_messages() 
  
  flow_mod['in_port']
  flow_mod['dst']
  flow_mod['actions']
  
  
  TypeError: string indices must be integers, not str
  </code></pre>