title: Paho(MQTT) client can't connect
body: <p>I'm using this python script to implement a basic Paho(MQTT) subscriber but under certain circumstances it doesn't invoke <strong>on_connect</strong>. </p>
  
  <p>I tried the following, all with exactly the same code:</p>
  
  <ul>
  <li>Running in a Raspbery pi, broker on desktop Pc (Ubuntu). <strong>Works</strong>.</li>
  <li>Running in a Pc(Ubuntu), broker on the same Pc. <strong>Doesn't work</strong>.</li>
  <li>Running in a Pc(Ubuntu), broker on other Pc(Ubuntu). <strong>Doesn't work</strong>.</li>
  <li>Running in a Pc(Ubuntu), broker.hivemq.com as broker. <strong>Works</strong>.</li>
  <li>Running in a Pc(Ubuntu), broker.hivemq.com (it's IP) as broker. <strong>Works</strong>.</li>
  </ul>
  
  <p>I also usually do:</p>
  
  <ul>
  <li>mosquitto_sub/pub in terminal in all previous combinations. <strong>Works</strong>.</li>
  <li>Official C++ paho wrapper in all previous combinations. <strong>Works</strong>.</li>
  </ul>
  
  <p>Also tried all setup methods listed in the official website. So python's paho library doesn't seem to be getting along with my local broker unless I run it from my raspberry. But using the same broker works well with c++'s paho library and if using MQTT from the terminal. Any ideas of what can be happening?</p>
  
  <pre><code>     import paho.mqtt.client as mqtt
  
       def on_connect(mqtt_client, obj, flags, rc):
           mqtt_client.subscribe("test")
           print "on_connect"
  
       def on_message(mqtt_client, obj, msg):
           print "on_message"
  
       mqtt_client = mqtt.Client()
       mqtt_client.on_connect = on_connect
       mqtt_client.on_message = on_message
       mqtt_client.connect("127.0.0.1",1883)
       mqtt_client.loop_forever()
  </code></pre>