micropython-iot-hackathon icon indicating copy to clipboard operation
micropython-iot-hackathon copied to clipboard

NodeMCU won't connect to MQTT "Broker"

Open eayoungs opened this issue 8 years ago • 1 comments

Setup:

Client

  • NodeMCU Board
  • TSL2591 sensor: Adafruit

Broker

  • Lenovo ThinkPad X61 ~2006
  • Ubuntu 14.04 LTS
  • Mosquitto: MQTT v3.1

When I connect to the network, using mpfshell, I get the following response: "Wifi connect successful, network config: ('192.168.43.87', '255.255.255.0', '192.168.43.1', '192.168.43.1')"

I check that port 1883 is open with this command: netstat -ntlp | grep 1883 ...and I get this response: tcp 0 0 0.0.0.0:1883 0.0.0.0: LISTEN -
tcp6 0 0 :::1883 :::* LISTEN -*

I check the mosquitto MQTT broker (my X61 Thinkpad) with two terminals as described on Read the Docs and get the response, as expected.

When I try to connect to the the Broker, with this command: m = MQTTWriter('esp8266', 'IP_VERIFIED_WITH-WHAT_IS_MY_IP', 1883, 'sensor-data')

I get the following response.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mqtt_writer.py", line 13, in __init__
  File "mqtt_writer.py", line 17, in _connect
  File "umqtt/simple.py", line 56, in connect
OSError: [Errno 103] ECONNABORTED

I've tried different networks, making sure each time that both devices are on the same network. I've searched the web for the error but can't find any help online.

I'm so close and I have so many projects that I want to use this with. Any advice would be greatly appreciated!

Thanks in advance!

eayoungs avatar Aug 25 '17 02:08 eayoungs

Hmm. That is a strange one. Here are a few ideas that you might look into:

Is port 1883 really open to the outside world? If you have a firewall turned on (e.g. ufw), it probably blocks that port by default. If you have another linux box, you might run the mosquitto_pub utility and see if you can remotely publish to the broker.

Is your ESP8266 really on the network? You might look at your WiFi access point and see if you see the connection.

Have you switched networks? The connection parameters seem to be stored in nonvolatile memory, and it will connect to the last network automatically during the boot process. If you have switched networks at some point, you might try forcing a disconnect from the WiFi network and then reconnecting.

Let me know if that helps...

jfischer avatar Aug 25 '17 17:08 jfischer