Debugging MQTT

Posted on
  • Hi, am struggling to get MQTT working on ESP8266.
    I have numerous actual Espruinos (eg Espruino Wifi), and this code runs fine:

    const mqtt = require("tinyMQTT").create('.... url of local hivemq server ...');
    mqtt.on('error', function(err){console.log(err)})
    mqtt.on('connected', function(){console.log('connected')})
    
    var wifi = require("Wifi");
    wifi.connect("...", {password:"...."}, function(){
      console.log("wifi connected");
      mqtt.connect();
    });
    wifi.stopAP();
    

    Am able to connect to the MQTT server fine with a real Espruino, but with ESP8266 I get nothing, not even an error.

    This happens with the official MQTT library and tinyMQTT - work fine on Espruino WiFi, fails on ESP8266.

    Question: how to debug this and figure out what's wrong?

    David

  • I suggest to verify Wifi. Have a look at this snippet http://www.espruino.com/EspruinoESP8266#¬≠wifi

  • Question: how to debug this and figure out what's wrong?

    You can type mqtt in left side of the WebIDE to get details about the status.

    Edit:

    Sample output for not connected to the broker:

    >mqtt
    ={
          svr: "test.mosquitto.org",
          prt: 1883, ka: 60, usr: undefined, pwd: undefined, cn: 0,
          ri: 2000, wt: undefined,
          wp: ""
     }
    > 
    
  • Readme for tinyMQTT has been update.

  • Running an Espruino with a ESP8266 connected for WiFi (Any Espruino and a UART connected ESP8266 for WiFi communication only, including an Espruino-Wifi) is different from actually running all on an ESP8266 or ESP32: for latter, the separation and store and forward type of communication / buffering is missing, and in case of the ESP8266, the processing resources become quickly an issue: JS (application) execution streaks can keep the single processor busy only for a limited time, after that, ESP8266 Wifi stack has to get the control otherwise it 'browns out'... restarts.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Debugging MQTT

Posted by Avatar for DavidM @DavidM

Actions