Am I doing something wrong with the server for https://github.com/adamvr/MQTT.js? I see client.id
come in fine. Everything else comes in as undefined; I verified the MQTT client's info with another broker using 3.1 user/pass, so I know the issue is not there.
clients = { }
server = mqtt.createServer (client) =>
console.log 'Broker:mqtt:createServer'
# Catch when client connects
client.on 'connect', (packet) =>
console.log 'Broker:connect'
client.connack
returnCode: 0
client.id = packet.client
console.log 'version: ' + client.versionNum # undefined
console.log 'client: ' + client.id # COMES THROUGH FINE!
console.log 'username: ' + client.username # undefined
console.log 'password: ' + client.password # udefined
clients[client.id] = client
console.log 'clients: ' + JSON.stringify clients
...
server.listen 1883
I also created an issue under the project: https://github.com/adamvr/MQTT.js/issues/22
The client object you receive on the connect
event doesn't contain any of the parameters you're seeking. The only reason client.id
has the correct value is because you're setting it in the line above. The packet
passed with the event contains the properties.
clients = { }
server = mqtt.createServer (client) =>
console.log 'Broker:mqtt:createServer'
# Catch when client connects
client.on 'connect', (packet) =>
console.log 'Broker:connect'
client.connack
returnCode: 0
client.id = packet.client
console.log 'version: ' + packet.versionNum
console.log 'client: ' + packet.client
console.log 'username: ' + packet.username
console.log 'password: ' + packet.password
clients[client.id] = client
console.log 'clients: ' + JSON.stringify clients
...
server.listen 1883