-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
// Server
const mqttServer = require('mqtt-server');
const servers = mqttServer({
mqtt: 'tcp://localhost:1883',
mqtts: 'ssl://localhost:8883',
mqttws: 'ws://localhost:1884',
mqtwss: 'wss://localhost:8884'
}, function(client){
client.connack({
returnCode: 0
});
});
servers.listen(function() {
console.log('listening!');
});
// Client
const mqtt = require('mqtt')
// const client = mqtt.connect('mqtt://test.mosquitto.org')
const client = mqtt.connect('tcp://localhost:1883');
client.on('connect', function () {
client.subscribe('presence', function (err) {
if (!err) {
client.publish('presence', 'Hello mqtt')
}
})
})
client.on('message', function (topic, message) {
// message is Buffer
console.log(message.toString())
client.end()
})
Error:
/home/karl/dev/javascript/sandbox.js:11
client.connack({
^
TypeError: client.connack is not a function
at /home/karl/dev/javascript/sandbox.js:11:10
at Server.<anonymous> (/home/karl/dev/javascript/node_modules/create-stream-server/index.js:13:5)
at Server.emit (events.js:215:7)
at TCP.onconnection (net.js:1546:8)
Seems to be broken?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels