mqtt-vue-hook icon indicating copy to clipboard operation
mqtt-vue-hook copied to clipboard

ca support

Open donnie-kerr opened this issue 10 months ago • 0 comments

I am trying to connect to a broker via WSS using a ca cert. I is failing to connect and a in the error is undefined so I do not know why it is failing. Is this method of connecting using a pem file supported? If not, how do I change it to at least get an error back? `async loadCert() {

  const response = await fetch('ca-chain.pem');
  return await response.text();
},
async connectMqtt() {
  const clientIdUnique = Math.random().toString(16).substring(2, 10);
  
 const protocol = 'wss'
 const host = `XXXX`
 const port = 8882
 
  const options = {
    clientId: `aiassistant`,
    clean: true,
    keepalive: 60,
    protocolId: "MQTT",
    username:"XXXX",
    password:"XXXX",
    ca: [await this.loadCert()],
  };


  this.mqttClient = mqtt.connect(
    `${protocol}://${host}:${port}`,
    options
  );

this.mqttClient.on("error", function (a) { console.log("error!" + a); }); `

donnie-kerr avatar Jan 09 '25 16:01 donnie-kerr