chameleonbr / node-red-contrib-redis

Node RED client for Redis with pub/sub, list, lua scripting and other commands support.
MIT License
46 stars 42 forks source link

Redis in keeps connected after removal of redis in. #15

Closed rjbaat closed 4 years ago

rjbaat commented 6 years ago

Hi All, When i add a redis in node with BLPOP i get data incoming. Then i remove the node and it will still keep incoming data in my debug node. So it looks like the disconnect isn't done when removing the redis in node. I have this issue with 0.19.0 of node red and installed by manage pallete.

Maiquu commented 5 years ago

Each redis-in connection uses unique ioredis connections while other nodes in the library share these connections. But same disconnect method was used in all the nodes including redis-in. Resulting in connections being kept alive even after node is deleted or the flow that node belongs to is disabled.

function RedisIn(n) {

        node.on('close', function(done) {

            if (node.command === "psubscribe") {
                node.client.punsubscribe();
            }
            else if (node.command === "subscribe") {
                node.client.unsubscribe();
            }
            if (node.sto !== null) {
                clearInterval(node.sto);
                node.sto = null;
            }
            node.status({});
            node.client.disconnect();  /* Add This Line*/ 
            disconnect(node.server); /* This line wont disconnect from client in Redis-in's case*/
            node.topics = [];
            done();
        });
}
DarkAxi0m commented 5 years ago

I know it's nearly a year, but is there an update to this?

chameleonbr commented 5 years ago

This node now has a different strategy, Redis In now uses exclusive connection and others share the same connection optionally.

chameleonbr commented 4 years ago

Hi, I make 2 big updates in this project, if you still use this module please give me a feedback.