1

I'm new with MQTT and want to create MQTT client using node.js which accepts authentication header to connect to MQTT. URL to connect is tcp://ip_address:61616 and needs username and sessionId. [Server uses activeMQ].

Please help me with this.

7
  • 1
    Stackoverflow is not here to write code for you, you have to try and if you get stuck show us what you've done and somebody will help you fix it. Commented Jul 29, 2017 at 12:04
  • 1
    @hardillb I'm aware that no one will write code for me. I tried so many things and after that I'm asking this question to community. If you can't help than at least don't discourage peoples. Thanks for your valuable time and suggestion. Commented Jul 29, 2017 at 17:16
  • If you have tried something then show us what you've tried and we'll help fix it, but as it stands this question show absolutely no indication you have even tried to google or follow some of the many available examples. Also please read the doc on asking good questions stackoverflow.com/help/how-to-ask Commented Jul 29, 2017 at 17:20
  • I tried for this for whole 5 days and I can't put all over here. Commented Jul 29, 2017 at 17:26
  • @hardillb as stated in my question I'm totally new with mqtt and don't know proper functioning of it as well. Commented Jul 29, 2017 at 17:27

1 Answer 1

1
var mqtt = require('mqtt')
var client  = mqtt.connect('tcp://ip_address', {
  port: 61616,
  username: 'myuser',
  clientId: 'myclientid'
})
Sign up to request clarification or add additional context in comments.

2 Comments

I tried this bt it not worked. Is there any way by which I can check that I'm hitting right ip address?
Edited. Added port as separate option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.