我正在使用以下代码使用 MQTT 协议连接到云,但我不知道如何使用 SSL\TLS 属性进行连接。
var mqtt = require('mqtt');
var options = {
port: 8083,
host: 'wss://ovs.kontakt.io',
clientId: 'mqttjs_' + Math.random().toString(16).substr(2, 8),
username: 'test',
password: '*******',
rejectUnauthorized: false
};
var client = mqtt.connect('wss://ovs.kontakt.io', options);
client.on('connect', function() { // When connected
console.log('connected');
// subscribe to a topic
// publish a message to a topic
});
client.on('error', function(err) {
console.log(err);
});