在服务器上,我正在收听订阅并记录它们
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()
})
但我无法发送其他人......可能是因为我注意到客户正在取消订阅该主题。为什么会发生退订?