title: Why is the on_publish callback being called before on_connect?
body: <p>My output for the code that I have written is</p>
  
  <pre><code>on_publish
  ('Connected', '0')
  ('message received ', 'test1234')
  ('message topic=', u'paho/test')
  </code></pre>
  
  <p>Code is as follows:</p>
  
  <pre><code>import paho.mqtt.client as mqtt  
  import time import json
  
  def on_connect(client,data,flag,rc):
      print("Connected",str(rc))
  
  def on_publish(client,data,msg):
      print("on_publish")
  
  def on_message(client, userdata, message):
      print("message received " ,str(message.payload.decode("utf-8")))
      print("message topic=",message.topic)
  
  broker_address="iot.eclipse.org"
  
  client = mqtt.Client()
  
  client.on_connect=on_connect
  client.on_publish=on_publish 
  client.on_message=on_message 
  
  client.connect(broker_address,1883) #connect to broker 
  client.loop_start()  
  data="test1234" 
  client.subscribe("paho/test") 
  client.publish("paho/test",data) 
  time.sleep(4) # wait 
  client.loop_stop() #stop the loop
  </code></pre>