monstrenyatko / ArduinoMqtt

MQTT client for Arduino
MIT License
72 stars 13 forks source link

Got error Exception(28) when lost power in modem. #8

Closed tarzan115 closed 7 years ago

tarzan115 commented 7 years ago

Hi @monstrenyatko me again 😄 I got Exception(28) when call function mqtt->yield(30000L); in loop() function in ESP8266 when I turn off my WiFi modem. I tried to test in so many cases and I figure out is in mqtt->yield(30000L) function. and I also try in your example. It was the same. could you please check that.

thank you so much.

monstrenyatko commented 7 years ago

@tarzan115 You could have such kind of exceptions on ESP when read function is called without the actual network available. The MqttClient::yield polling the read to receive packets.

monstrenyatko commented 7 years ago

@tarzan115 I can't reproduce your issue. After change [a1e83f84984e6b968f77e3508bcb608e12529dc8] the cycle method performs verification if network is available. If the network is not connected It will not try to read the new packet from the network.

Could you please provide the code example to reproduce this.

tarzan115 commented 7 years ago

I just use original your example ConnectEsp8266WiFiClient I create a hotspot and setup for ESP8266 connect to. and then I turn that hotspot off. Esp8266 got Error Exception(28).

monstrenyatko commented 7 years ago

@tarzan115 Could you please share the stack trace of the exception?

Need to identify: 1) the exact ESP API throwing the exception 2) if the WiFiClient::connected() are able to detect the WiFi disconnection quickly enough

monstrenyatko commented 7 years ago

The problem was with WiFiClient::read call after the network disconnection. I don't know why ESP implementation throws the exception instead of just returning the error status... Improved NetworkClientImpl template should resolve the problem.