-
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
client with clean:false does not resubscribe #749
Comments
The broker should automatically subscribe you. |
Thanks Matteo. We are using mqttjs with rhel-amq (wrapped on apache amq). Any inputs on this will be appreciated. Steps.
Subscriber const mqtt = require('mqtt');
let brokerUrl = 'mqtt://localhost:1883';
const client = mqtt.connect(brokerUrl, {
clean: false,
clientId: 'solo-consumer',
});
client.on('connect', function () {
console.log('i am going to subscribing');
client.subscribe('HelloTopic', { qos: 1 }, () => {
console.log('i have subscribed')
});
});
client.on('message', (topic, message) => {
console.log(message.toString() + '\n');
}); Producer const mqtt = require('mqtt');
let brokerUrl = 'mqtt://localhost:1883';
const client = mqtt.connect(brokerUrl, {
clean: false,
clientId: 'solo-producer',
});
let msgCount = 0;
client.on('connect', function () {
setInterval(function () {
const payload = 'Message : ' + (msgCount++);
client.publish('HelloTopic', payload, () => {
console.log(payload);
});
}, 3000);
}); Thanks, |
Is the client emitting an Have you checked if the same code work with Mosquitto? I fear it might be a problem with Rhel AMQ configuration, and you should check with them. |
Hi Matteo, The same problem occurs on Mosquitto as well. Have tested it.
Steps to recreate
NOTE : The connect & subscribe block do execute, but the 'on message' does not receive any. The client is expected to be restarted. (More Finding) : A forced 'unsubscribe' inside the 'connect' callback and 'subscribe' after it, works as expected on broker restarts.
Thanks |
Is persistent storage configured in both brokers? |
Yes. Persistence is enabled on both. |
Can you please share the Mosquitto configuration that you are using? |
For the record I am experiencing the same issue. We use AMQ as well (5.14.5) and had not noticed the issue in test and dev as we use docker compose and made our mqtt client services dependent on AMQ which when it was restarted they were as well (I think). In our case we have perhaps 500+ topics and subscribe on the consuming side using wildcards so resub is not onerous. I have added the work around described above and indeed it solves the problem but to be honest I am not convinced that the issue is that deterministic as reproducing the issue was not always guaranteed. |
I think we have the same problem, but broker is EMQ. For some reason, it looks like the client stops working after a reconnect in some cases. We also use the {clean: false} configuration. we're using 2.7.1 at the moment. |
I have the same problem, broker is EMQ. mqttjs(4.2.1) client with |
|
We notice that the client is not resubscribing when
{clean: false}
option. The code in resubscribe block ofindex.js
as well does this.Would it be possible to resubscribe when the client has clean:false options set for receiving QOS:1 messages ?
Thanks
The text was updated successfully, but these errors were encountered: