You are reading a single comment by @Ickis and its replies. Click here to read the full conversation.
  • Actually can you try this instead:

    mqtt.on('publish', function (pub) {
        console.log(JSON.stringify(pub));
    });
    

    It looks like 'publish' can return undefined if it doesn't understand the MQTT packet that it was sent, which would produce your error

  • Gordon, thank you, i'll definitely try with json. I already looked through module code and and notice, when it can be undefined, so run my code without pub.topic and pub.message. mqtt.on('publish', ...) can catch the event, thats good. But still need to read messages for my project and still look for solution. Will try use JSON.stringify(pub) today and tell about result.

    And about first problem: it was solved when i set my options object as a parameter of 'create' function like this: mqtt.create (server, options);
    setting client_id didn't help, but i tried :)
    By the way, I still have issue in the connect (a.write dose not already exist, if i'm not mistaken), but this solution let mqtt run, so for now i just ignore the issue.

About

Avatar for Ickis @Ickis started