-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
connAckPacket.sessionPresent is not checked for mqtt3.1.1 #1288
Comments
Hey @yyjdelete thanks for identifying this. could you provide a repro example so I can run it and identify this bug and that the fix handles it? |
@YoDaMa var mqtt = require('mqtt')
var cid = 'mqttjs_' + Math.random().toString(16).substr(2, 8)
var i = 0
var test = function(testSessionExpire){
//test with an local mosquitto or other server
var client = mqtt.connect('mqtt://127.0.0.1', {
clean: false,
clientId: cid,
//protocolVersion: 5,
reconnectPeriod: testSessionExpire ? 1000 : 0
})
client.on('connect', function () {
console.log('connect=>' + (++i))
client.subscribe('presence', function (err) {
console.log('presence', err)
if (!err) {
client.publish('presence', 'Hello mqtt=>' + (+new Date()))
}
})
})
client.on('message', function (topic, message) {
// message is Buffer
console.log(message.toString())
if (testSessionExpire)
console.log('Please restart mqtt server now')
else
setTimeout(()=>test(false), 1000)
})
}
test(true) As you can see, subscribe didn't report any error, but the second
|
MQTT 5.0.0 BETA is now available! Try it out and give us feedback: |
Seems #917 only add check for it when mqtt5.0 is used, but the flag is also available and should also be checked for mqtt3.1
This will make resubscribe and later manually subseibe with the same topic failed if
option.clean
is set tofalse
but sever already clean the session when reconnected.MQTT.js/lib/client.js
Line 1453 in 37b12cb
The text was updated successfully, but these errors were encountered: