Tuesday 30 May 2017

how can i send the username and password from one client to broker in MQTT?

can anyone tell me how to send username and password from client to broker in MQTT in nodejs? and how to filter the clients in broker based on username and password.This is client code .can anyone upload broker code with filering some clients based on username and password.Thanks in advance ... I am waiting for your reply.

CLIENT CODE:



var mqtt=require("mqtt");
var express=require("express");
var app=express();
var options={
    keepalive:10,
    port: 1883,
    clientId:'2',
    host: "http://localhost:8000",
    will:
        {
            topic:'willMag',
            payload:"connection closed abnormallly",
            qos:0,
            retain:false
        }
};
var client=mqtt.connect("tcp://192.168.43.28:1883",options);
client.on("connect",function()
{
    client.publish("ranjith/princy","hello love you",function()
    {
        console.log("message published");
    });
    client.subscribe("ranjith/princy");
    client.on("message",function(topic,message)
    {
        console.log("I recieved the topic:"+topic);
        console.log("I recieved the message:"+message);
    });
});

app.listen(8000,function()
{
    console.log("server listen at port 8000");
});


via vigneshRavi

No comments:

Post a Comment