Skip to content

TypeError: client.connack is not a function #6

Description

@basickarl
// 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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions