MQTT authorization now required?

Posted on
  • Trying to use test.mosquitto.org/. I get a message saying "not authorized". Upon visiting their page, it says I need to use the cert, even for the unencrypted ports. On Espruino.com/MQTT, it says encryption and authentication are not implemented. So Espruino just doesn't work with the public brokers right now?

    Below is the code I was using. Instead I'm using Mosca on local now and I have a working connection.

    var WIFI_NAME = "XXXXXX";
    var WIFI_PASS = "XXXXXX";
    
    var wifi = require("EspruinoWiFi");
    
    var broker = "37.187.106.16";
    var options = {
      client_id : "random",
      keep_alive: 60,
      port: 1883,
      clean_session: true,
      username: "username",
      password: "password",
      protocol_name: "MQTT",
      protocol_level: 4,
    };
    var mqtt = require("MQTT").create(broker, options);
    
    mqtt.on('connected', function() {
      mqtt.subscribe("test/espruino");
    });
    
    wifi.connect(WIFI_NAME, { password: WIFI_PASS }, function(err) {
      if (err) {
        console.log("Connection error: "+err);
        return;
      }
      console.log("Connected!");
      mqtt.connect();
    });
    
  • test.mosquitto.org/ seems to imply that port 1883 is still unencrypted, and doesn't need a certificate.

    The not authorized is probably because you've got:

      username: "username",
      password: "password",
    

    What happens if you just remove those?

    But even for the encrypted comms, you can still use TLS with Espruino WiFi and/or the Pico.

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

MQTT authorization now required?

Posted by Avatar for CriscoCrusader @CriscoCrusader

Actions