Can't connect to mqtt broker
<p>I installed MQTT broker Mosquitto on my pi and are having some problems getting it to work with boxes in my network. Locally, if I putty in to the RPi running the Mosquitto MQTT broker everything is OK. I can use the client commands (<code>mosquitto_sub, mosquitto_pub</code>) to subscribe and publish to topics, no problem. BUT, if I try to connect from another box, Win2k12 server with a python script it states it cant connect.</p>

<ul>
<li>I've tried turning the firewall off in my router</li>
<li>I've tried turning the firewall off on my Win2k12 server</li>
<li>I've added TCP 1883 to allowed ports outbound from my Win2k12 server</li>
</ul>

<p>The Python script:</p>

<pre><code>import paho.mqtt.client as mqtt

def on_connect(client, userdata, flags, rc):
    client.publish("test_mqtt", "test")
    client.subscribe("test")

def on_disconnect(client, userdata, rc):
    print("Disconnect, reason: " + str(rc))
    print("Disconnect, reason: " + str(client))

client = mqtt.Client("testclient")
client.on_connect = on_connect
client.on_disconnect = on_disconnect
client.connect("192.168.1.20", 1883, 60)
client.loop_forever()
</code></pre>

<p>The output here is</p>

<pre><code>Disconnect, reason: &lt;paho.mqtt.client.Client object at 0x01F41EF0&gt;
Disconnect, reason: 1
</code></pre>

<p>I've tried to have a look at <a href="https://eclipse.org/paho/clients/python/docs/#callbacks" rel="nofollow noreferrer">the documentation</a> but it only mentioned the flags, not defining what they are.</p>

<p>The raspberry pi that is running Mosquitto is also running Node-red. It has no problem connecting to the MQTT broker (both of them are running on the same rpi)</p>

<p>Has enyone set up MQTT on Raspberry Pi and got it to work with other devices? I want it to work with a NodeMCU thingy, but when I had problems I started working on a python script to further debug the problem.</p>