【发布时间】:2016-05-22 20:17:00
【问题描述】:
在服务器上我正在收听订阅并记录它们
mqttServ.on('subscribed', (topic, client) => {
mqttServ.publish({
topic: topic,
payload: `client ${client.id} subscribed`,
qos: 1
}, client)
})
mqttServ.on('unsubscribed', (topic, client) => {
console.log(
`client ${client.id} unsuscribed from topic ${topic}`
)
})
在客户端我正确收到第一条消息
client.on('connect', () => {
client.subscribe('goodmorning')
})
client.on('message', (topic, payload) => {
console.log([topic, payload].join(": "))
client.end()
})
但我无法发送其他人...可能是因为我注意到客户正在取消订阅该主题。 为什么会发生退订?
【问题讨论】:
标签: node.js websocket mqtt mosca