Skip to content
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

Inflight messages / QoS 1 support for instance.publish() #67

Closed
yentsun opened this issue Sep 22, 2016 · 4 comments
Closed

Inflight messages / QoS 1 support for instance.publish() #67

yentsun opened this issue Sep 22, 2016 · 4 comments

Comments

@yentsun
Copy link

yentsun commented Sep 22, 2016

Hi, Matteo!

I appreciate your work very much since Mosca, and having an embedded broker with custom auth is awesome!

I'm having some issues with achieving QoS 1 behavior when publishing from the broker (not from a client) though. I've set up aedes-redis-persistence and retained messages work fine:

 instance.publish({topic: 'cloud/update', payload: buffer, retain: true})

and I can see them in Redis. But if I try to

instance.publish({topic: 'cloud/update', payload: buffer, qos: 1})

instead - I don't see any inflight messages while no clients connected.

I actually switched to Aedes from Mosca in hope to achieve this, but still no luck. Retain also worked in Mosca but no inflight messages for QoS 1 stored. Maybe I'm doing something wrong?

@mcollina
Copy link
Collaborator

You need to subscribe your clients with clean:false.

@yentsun
Copy link
Author

yentsun commented Sep 22, 2016

@mcollina thanks for the quick response! I guess I'm doing it already (I'm using the mqtt-spy client). Ok, I will conduct more tests with different clients.

@yentsun
Copy link
Author

yentsun commented Sep 22, 2016

the first test with mqtt.js:

var mqtt = require('mqtt');
var client  = mqtt.connect('mqtt://localhost', {clean: false, clientId: 'hkkm65'});

client.on('connect', function () {
    client.subscribe('cloud/5rbo2n/update', {qos: 1}, function(error, granted) {
        console.log(error, granted);
    });
});

client.on('message', function (topic, message) {
    // message is Buffer
    console.log(message.toString());
    client.end()
});

...proved the outgoing messages do work, could see them in Redis too.

As for anybody using mqtt-spy, Clean session checkbox doesn't seem to work.

Thanks, Matteo! Sorry to bother with this.

@yentsun yentsun closed this as completed Sep 22, 2016
@mcollina
Copy link
Collaborator

No problem @yentsun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants