Git Product home page Git Product logo

Comments (15)

mcollina avatar mcollina commented on May 16, 2024

Can you please upload a client & server to reproduce? Ideally in Node.js.

from aedes.

guptaashishiitr avatar guptaashishiitr commented on May 16, 2024

Broker file as below and logger file just generates logs to check if there are any errors. I have removed publish auth and sub scribe auth/connect auth from the file. Client you can pretty much use any (even any browser based or light weight client will do) Settings for client are

  1. QOS 2
  2. Clean : false
  3. KeepAlive - 300

aedes version - 0.20.0
aedes-persistence-redis version - 2.3.0

(We have connect auth also but you can skip that)
Steps

  1. Subscrible client 1 to a topic (Redis will show cached subscriptions and client)
  2. Disconnect and connect client 2 (Redis will show cached subscriptions and client)
  3. Publish to topic client 1 has above about 10 mesages with qos 2 / retained as false
  4. Disconnect and connect back as client 1 and subscrible to topic

If you want exact files and tests let me know, I can write quick node project.

`
// MQTT Broker Setup
var logger = require('./config/logger');
var common = require('./config/common');
var config = common.config()

function aedesConnect() {
var redispersistence = require('aedes-persistence-redis')({
host: config.REDIS_CONNECTIONURL,
port: config.REDIS_PORT,
password: config.REDIS_PASSWORD
});

var aedes = require('aedes')({
    persistence: redispersistence,
    connectTimeout: config.MQTT_CONNECTTIMEOUT
});

var aedesServer = require('net').createServer(aedes.handle)

var settings = {
    port: config.MQTT_PORT,
};

// Authentication method
aedes.authenticate = function (client, username, password, callback) {
    var authorized = true
callback(null, authorized);
}

// Authorize Publish Method
aedes.authorizePublish = function (client, packet, callback) {
return callback(null)
}

////Authorize Subscribe Method
aedes.authorizeSubscribe = function (client, sub, callback) {
    callback(null, sub)
}


var port = 1883

aedesServer.listen(port, function () {
    logger.info('mqtt broker listening on port ' + port)
})


aedes.on('clientError', function (client, err) {
    logger.error(err)
    logger.error('client error', client.id, err.message)
})

aedes.on('clientDisconnect', function (client) {
    logger.info('Client disconnected - ', client.id)
})

aedes.on('unsubscribe', function (unsubscriptions, client) {
    logger.info('Client unsubscribed - ', client.id, unsubscriptions.toString())
})

aedes.on('publish', function (packet, client) {
    if (client) {
        logger.info('message published from client', client.id, " to ", packet.topic, packet.messageId)
    }
    else {
        logger.info('message published from broker to ', packet.topic, packet.messageId)
    }
})

aedes.on('client', function (client) {
    logger.info('new client', client.id)
})

return aedes;

}

module.exports = aedesConnect
`

from aedes.

mcollina avatar mcollina commented on May 16, 2024

I cannot reproduce, things works smoothly here. Please upload a test client that makes the server exhibit the bug.

I am publishing a QoS 2 message with retain:false using MQTT.js.

Which version of Redis are you using? I'm testing on 3.2.0.

from aedes.

guptaashishiitr avatar guptaashishiitr commented on May 16, 2024

I am using redis version 3.0.3
I will replicate it with MQTT.js and paste details here

from aedes.

guptaashishiitr avatar guptaashishiitr commented on May 16, 2024

@mcollina We were facing a lot of issues and have switched to mosquitto and we have had no problems since then. I definitely want to contribute to this amazing project and will add sample client files to replicate the issues but to summarize issue is -

QOS2 offline messages are not delivered in order and all of them are not delivered but in chunks of 4 or less. So if I sent 10 messages when client 2 is disconnected, whenever it conencts back it wont get all 10 and also in random order.

Will add sample client files and broker files in couple of days as we are having a release tomorrow.
Thank you for all the help.

from aedes.

mcollina avatar mcollina commented on May 16, 2024

I've done another round of testing, confirmed odd behavior both with redis and without.

Thanks for reporting, I'll look into it as soon as possible (it might take a while).

from aedes.

igormontella avatar igormontella commented on May 16, 2024

Hello @mcollina, could you describe the error, I'm facing the same problem, the clients are receiving the same message multiple times.
If could you describe it a bit, I could help and make a PR.

Thanks!

from aedes.

mcollina avatar mcollina commented on May 16, 2024

@igormontella thanks! Really, I have just tested the above code. This needs to be triaged and debugged, feel free to dig into it and report with any questions, it will make solving this much quicker.

from aedes.

GavinDmello avatar GavinDmello commented on May 16, 2024

@guptaashishiitr @igormontella We made some change in aedes-persistence redis. Could you guys check if you're still facing this issue ?

from aedes.

rasalasantosh avatar rasalasantosh commented on May 16, 2024

@GavinDmello , Offline messages are not delivered in order ,tested with both QoS1 and Qos2 .

from aedes.

GavinDmello avatar GavinDmello commented on May 16, 2024

@rasalasantosh Are you getting all of them though ?

from aedes.

rasalasantosh avatar rasalasantosh commented on May 16, 2024

@GavinDmello ,yes all are delivered.

from aedes.

GavinDmello avatar GavinDmello commented on May 16, 2024

@rasalasantosh Got it @mcollina I think scan returns data in random order

from aedes.

mcollina avatar mcollina commented on May 16, 2024

I'm starting to think that using SCAN was not a good idea in the first place. Maybe we should go for the same approach of Mosca.

from aedes.

GavinDmello avatar GavinDmello commented on May 16, 2024

I think this should be solved in the latest version of redis persistence redis

from aedes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.