Hass.io mosquito MQTT and NodeMCU ESP8266 MQTT keeps trying to connect after connecting

I did a search but was not able to find a similar question.

I an still very new to home assistant and this is my first shot at any nodeMCU ESP-8266 project

I have set up mosquito in Hass.io and have uploaded the script to a Node MCU ESP 8266 to control my WS 2811 Led lights.

The Node MCU connects to my WiFi no problem and then attempts to connect to the MQTT service. It says it is connected in the log for mosquito in Hass.io and on the serial monitor for the nodeMCU board. but then it attempts connection right away.

Sometimes it does this a hand full of times before it has a sable connection sometimes it can go on for 20 minutes. would this be a problem with my mosquito setup, or node MCU board or my script.

make sure you have unique client IDs on every device that is communicating with MQTT.

1 Like

I have given its own ID and I only have the one device right now.

when it connects it works no problem. my problem is that it connects then attempts the connection again after it has connected.

Could this be a problem with the version of the PubSub client I am using?

could be. Or it could be a loop in your program that isn’t gracefully exiting

the program i am using can be found here all I did was input my wifi and MQTT info

https://github.com/Snipercaine/Holiday-LED-files/blob/master/OutsideLEDs_Public.ino

Personally I use

PubSubClient.cpp - A simple client for MQTT.
Nicholas O’Leary
http://knolleary.net

as it seems better at keeping a connection but it might be that you are too far away or the antenna is damaged on the board. If you use the one above you will have to change the code to match, it’s not plug and play :stuck_out_tongue:

I have put in my info for the wifi and MQTT info is there any other part of the code I would have to change?

Yep all of the pubsub parts, like I said it’s not plug and play.

If you don’t know what you are doing I wouldn’t attempt it.

If you can paste these two logs here, it might provide some useful information.