• Ok, yes - I think one problem might be that you're calling require("ESP8266WiFi_0v25").connect twice. In that case you now have two ESP8266 bits of code trying to run concurrently, which'll really mess things up!

    Try only initialising it once. Or if you feel you really have to do it twice, use clearTimeout() and Serial2.removeAllListeners() first.

    Also, you're trying to shut a socket and then immediately restart the ESP8266, before the command has even finished sending.

    Try tweaking your code to add a timeout as well:

    apServer.close();
    setTimeout(setup, 1000);
    
  • I tried adding Serial2.removeAllListeners() and tested, it does not work.
    I tried initializing the require("ESP8266WiFi_0v25").connect only once and tested, it does not work.

    But all the scenarios, if i make a new HTTP connection instead of client.connect() (not making any MQTT calls), i'm getting the response and the socket is not closed.

    I strongly believe that there is something to do with client.connect() , especially it happens only when i run/close the HTTP server first and try to connect to the MQTT.

About

Avatar for sureshkm @sureshkm started