Sempre que executo o código abaixo, a mensagem gerada no terminal é de que a conexão foi recusada:
import paho.mqtt.client as mqtt
mqttc = mqtt.Client()
mqttc.connect("iot.eclipse.org", 1883)
mqttc.publish("labrmerces/temperatura", "25")
mqttc.loop(2)
A mensagem de erro exibida é:
Traceback (most recent call last):
File "mqttClient.py", line 4, in <module>
mqttc.connect("iot.eclipse.org", 1883)
File "/usr/local/lib/python3.5/dist-packages/paho/mqtt/client.py", line 760, in connect
return self.reconnect()
File "/usr/local/lib/python3.5/dist-packages/paho/mqtt/client.py", line 887, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File "/usr/lib/python3.5/socket.py", line 711, in create_connection
raise err
File "/usr/lib/python3.5/socket.py", line 702, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused