Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

274
Views
How to connect to TLS using Vue?

I want to connect to MQTT server using Vue. I tried something similar to what I found on Google, but failed.

  • node.js example
var mqtt = require('mqtt');
var fs = require('fs');

var options = {
  host: '127.0.0.1',
  port: 8883,
  protocol: 'mqtts',
  protocolId: 'MQIsdp',
  ca: [fs.readFileSync('<path>/ca.crt')],
  key: fs.readFileSync('<path>/client.key'),
  cert: fs.readFileSync('<path>/client.crt'),
  passphrase: 'CLIENT KEY PASSPHRASE',
  secureProtocol: 'TLSv1_method',
  protocolVersion: 3
};


var client = mqtt.connect(options);
  • Results I wrote using a method I found on the blog
const option = {
      port: 48883,
      ca: [],
      key: '',
      cert: '',
      clientId: 'mqttjs_' + Math.random().toString(16).substr(2, 8),
      protocolId: 'MQTT',
      useSSL: true,
      passphrase: 'CLIENT KEY PASSPHRASE',
      secureProtocol: 'TLSv1_method',
      protocolVersion: 4,
      rejectUnauthorized: false,
    }

    axios.get('/' + 'ca.crt').then(response => {
     option.ca = [response.data]
    })

    axios.get('/' + 'client.key').then(response => {
     option.key = response.data
    })

    axios.get('/' + 'client.crt').then(response => {
     option.cert = response.data
    })
    
    
    const client = mqtt.connect('wss://url', option)
  • error code
failed: WebSocket is closed before the connection is established.
WebSocket connection to 'wss://url' failed: 
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!