You are reading a single comment by @Ickis and its replies. Click here to read the full conversation.
  • Hello!
    I'm trying to run mqtt client on my espruino. And have errors all the time. I tried to do it with options:

    function mqttRun(){
      var server = 'my_broker';
      var options = {
              keep_alive: 60,
              port: my_port,
              clean_session: my_port,
              username: "my_user",
              password: "my_pass",
              protocol_name: "MQTT",
              protocol_level: 4,
      };
      var mqtt = require("MQTT").create(server);
      mqtt.connect(options);
      mqtt.on('connected', function() {
        mqtt.subscribe("test");
      });
    }
    

    and as result got:

    Client connected
    Uncaught Error: Function "write" not found!  at line 1 col 35 ....log("Client connected");a.write(b.mqttConnect(b.clie­nt_id))...
                                  ^ in function "e" called from line 3 col 353 ..."close")});b.client=a};a?e():a=requir­e("net").connect({host:...
                                  ^ in function "connect" called from line 27 col 23   mqtt.connect(options);
                          ^ in function "mqttRun" called from line 1 col 9 mqttRun()
    

    Without options I tried to connect with eclipse sandbox, and it works different:

    mqttRun()
    ["AT+CIPSTART=0,\"TCP\",\"iot.eclipse.or­g\",1883\r\n"
    =undefined
    Client connected
    ] "\r\n" <--- "\r\n"
    ] "OK\r\n" <--- "OK\r\n"
    ] "\r\n" <--- "\r\n"
    ] "0, CO" <--- "0, CO"
    ] "0, CONNEC" <--- "NNEC"
    ] "0, CONNECT OK\r" <--- "T OK\r"
    ] "\n" <--- "\n"
    ] "\r" <--- "\r"
    ] "\n> " <--- "\n> "
    ] "\r\n" <--- "\r\n"
    ] "0, SE" <--- "0, SE"
    ] "0, SEND O" <--- "ND O"
    ] "0, SEND OK\r\n" <--- "K\r\n"
    ] "\r\n+RECEI" <--- "\r\n+RECEI"
    ["AT+CIPCLOSE=0,1\r\n"
    MQTT client disconnected
    MQTT client disconnected
    Uncaught Error: Unknown Interval
     at line 1 col 62
    ...ted");clearInterval(b.pintr);b.emit("­disconnected");b.emit("...
                                  ^
    in function called from system
    ] "+RECEIVE,0,4:\r\n " <--- "VE,0,4:\r\n "
    ] "+D,0,3:\x02\x00\x00" <--- "\x02\x00\x00"
    ] "\r" <--- "\r"
    ] "\n> " <--- "\n> "
    ] "\r" <--- "\r"
    ] "\n0, " <--- "\n0, "
    ] "0, SEN" <--- "SEN"
    ] "0, SEND O" <--- "D O"
    ] "0, SEND OK\r\n" <--- "K\r\n"
    ] "\r" <--- "\r"
    ] "\n0, " <--- "\n0, "
    ] "0, CLO" <--- "CLO"
    ] "0, CLOSE" <--- "SE"
    ] "0, CLOSED\r\n" <--- "D\r\n"
    

    Could I fix it somehow?

About

Avatar for Ickis @Ickis started