Mqtt in openhab not connected without internet

hi to all,

i am getting problem to connect mqtt in openhab without internet, i am use esp8266 node mcu and mcu connect with wifi but not able to connect with mqtt(“i am remove internet cable form router only lan calbe is plug”), and if i try to connect mqtt with mqtt-spy in my system so mqtt is connected but i am not able to connect via my phone using mqtt-dashbord, here i am attach my screen shot,


This may sound very basic but are you perhaps using a public MQTT broker?
Also… your ESP8266 shouldnt really crash if it can’t find the broker. Is your PSU OK?

Paste your arduino code so we can all check.

1 Like

here is my arduino file, but i think any problem in my arduino file, b’cust mqtt not connect without internet cable only esp connect with wifi but not connect with mqtt in openhab, and i am try to connect mqtt-deshboard app in my phone too but apps also not connect with mqtt , is really need internet work with openhab using mqtt and if answer is yes ?, is big problem for me b’cust i am use alexa and openhab apps in my phone, i know alexa is not work without internet but at list apps need to work without interner if is not prosibel so how can i control relay with our intenet and i not have any switch to on off in my home, is there any outer way to use openhab with arduino esp like http or any outer

new 1…xml (9.4 KB)

in your reconnect() function that is called in the main loop, you have this piece of code:

while (!client.connected()) {

This loop will continuously run until client is actually connected. Endless loops is a big no-no in ESP/mcus/avrs as most of them have WDTs. The wdt will hit causing your ESP to reboot.

if (client.connect((char*)
 else{Serial.println("\tFailed."); abort();}

You are explicitly call abort(), and I’m not sure why. If client cannot connect, let the loop continue, and have the client retry.

To fix your code, fix the while loop, and remove the else part that I pasted. Just change the while to an if

if (!client.connected()) {

This should keep the wdt happy also