So i got to a point where everything was working. to a certain point.
now it looks like i altered something in Openhab (possible the .cfg file) that the esp01 module connects and disconnects. and goes on an endless loop. it was doing nothing like this before.
so in my troubleshooting i have notice that it stops trying to reconnect and stays connected when i stop the openhab server.
i subscribed to the topic, and with openhab server not running, i received fine with no problems, but ofcourse my sitemap was not up.
then i restarted the openhab server and it starts the loop again.
Is your esp and openHAB trying to connect to the MQTT broker with the same client id? This would cause the other to disconnect each time a connection attempt was made.
Each client (for example your esp module is one client, openhab is a different client) must connect to the mqtt broker with a unique client id.
In the screen dump in your initial post, you have set the clientId to ESP1 in one of your connections, which seems to match the ESP1 in the init.lua program (I think this is the clientId, but I don’t have the api to hand). This would cause an error.
The simplest solution is to remove the clientId line from the openhab.org as by default openhab generates a fairly unique client id to connect with.
I’m not sure why you have defined several connections to the same broker (IP address and port). You only need one.
Also, I seem to remember generating the client id from the chip identifier on the ESP module, to make sure that is unique, for when you get more ESP modules connected.
Edit:
And another thought: the broker should produce an error log of what went wrong. You don’t say which broker you are using but mosquitto produces a log in /var/log/mosquitto (on debian type systems)