Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: client.connack is not a function #6

Open
basickarl opened this issue Dec 10, 2019 · 4 comments
Open

TypeError: client.connack is not a function #6

basickarl opened this issue Dec 10, 2019 · 4 comments

Comments

@basickarl
Copy link

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

@zwmmm
Copy link

zwmmm commented Dec 24, 2020

Solved?

@akiannillo
Copy link

no, same problem here.

@mcollina
Copy link
Member

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@akiannillo
Copy link

It was a problem in the read me. Simple pullrequest #7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants