v1.97 - bug in net module or I do something wrong?

Posted on
  • Now I try to connect MQTT client to my clock project. I have found that Espruino MQTT module does not work, because its onConnect() function is called twice when it is connected to server. I have just added workaround into the function and everything is working.
    Is it a bug in net module in the version or something else?

    I can add my code here, of course, but I think it is trivial - I just call require() and then connect().
    Workaround in first line of onConnect() is to check if #onend is already registered in socket and return if it is.

  • Yes, there was a bug caused by two onconnect events. However 1v97 is over 6 months old.

    Just move to the newest version of Espruino and you'll be fine.

  • @Gordon Thank you, now I am sure it does not seem to me. I have not checked neopixel in ESP32 v2.00. I have read it was broken in v1.98 and is not working now.
    In any case the old version bug is not a problem for my clock.

    By the way, I've found one minor bug in MQTT module:
    in MQTT.prototype._scktClosed

    if (this.ctimo) clearInterval(this.ctimo);

    should be clearTimeout

  • Thanks - I'll make sure that gets in the next update

  • Tue 2018.11.20

    May I ask @SergeP at what link you read this:

    re: neopixel: 'I have read it was broken in v1.98 and is not working now.'

    To my knowledge, hasn't been an issue. The change log doesn't indicate a fix for something that wasn't apparently broken:


    and only found a 1v98 forum reference at
    'Graphics.drawString not working on 1v98?'
    which isn't directly related to Neopixels.

    I can speak from experience that I've had no issue on several versions, the latest 1v99 on authentic Espruino boards, and have built quite sizable modules pushing the limits of both code and hardware.

    Would love to know where this bad press started.

  • Neopixels are still broken on the esp32 with version 2.00.

    Since the sdk was updated to v3.0 (and also 3.1) it has not worked. There was no changes around the RMT libs used output the waveforms,so it's a bit of a mystery. @jumjum is going to connect a digital oscilloscope at some stage.

    The outstanding issue is here:


    We have bigger issues with wifi not connecting at present with the latest sdk so will be reverting back to 3.0.x

    The ESP-idf is a moving target - we update to get new features, and then other things break. It's very frustrating!

  • @Gordon I' ve found something to improve in MQTT module.
    In some cases call of underlying require("net").connect(...) throws exception. mqo.emit('disconnected') is not called in such case. So general reconnection algorithm (reconnect on disconnected) is not working.
    So may be it is a good idea to catch the exception in MQTT module and emit disconnected event:

          try {
            client = require("net").connect({host: mqo.server, port: mqo.port}, onConnect);
          } catch (e){
            client = false;

    It will simplify usage of MQTT module.

  • ref #6

    Thank you @Wilberforce for the detail outlining that, this is specific to ESP32 and not authentic Espruino devices. That should resolve the confusion here.

  • @SergeP thanks - I'll get that added.

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

v1.97 - bug in net module or I do something wrong?

Posted by Avatar for SergeP @SergeP