Someone with experience with REDIS subscribing?

Hi,

I have no experience with REDIS yet, but for one of my flows I need to subscribe to a REDIS .

I tried this : https://flows.nodered.org/node/node-red-v4-contrib-redis

And loaded the example flow, but everything I get in debug is :

Error: connect ECONNREFUSED 127.0.0.1:6379

I checked different things including the config node but could not find anything... including maybe a way to set the IP, port, password and so on.

If anyone has some knowledge about that, I'd be happy to lean.

Thanks !

The obvious questions are

  • have you installed redis on the same computer
    • is node-red or redis running on the OS or in docker/VM?
  • is redis setup to use port 6379
  • do you have a firewall blocking that port?

Thanks,

my bad, I thought I would not need any additional set-up than the nodes for some kind of local redis PUBLISH / SUBSCRIBE to work.... so I checked for some more information and know understand I have to install a REDIS server as well.

So for my understanding, every devices interested in REDIS messages have to run a REDIS server ?

Or could that work as well, if I specify as a REDIS server the unit from which I have to subscribe to messages ? Guess It has to run a REDIS server as well...

And other question, how to handle the password security, which I know is being used for the REDIS channel I want to subscribe ?

Many thanks !

No.

One redis server is enough.
Client A writes on redis.
Client B reads on redis.
Or vice-versa.

You have to know what "the unit" is doing.

Redis is a key/value pair database.

If you don't know the key(s) it is possible to get them. Nevertheless, on an active redis instance it is like finding a needle in a haystack.

Then, for the password, I have neved used redis on nodered with passwd.

The redis contrib nodes works well, but, the documentation is "challenging" (aka. inexistent)

Thanks a lot for your message.

I found some information to set the Redis config node, for now it seems to accept the connection use this kind of JSON in config node :

image

Now what I need is to find what to enter as a topic in the Redis In node. the help is not really helpful to me yet : The msg.topic is pattern on all methods, separated by spaces.

But I will continue investigating in it ....

Told you. Challenging documentation.

If often used the redis.io documentation and "translate" for this implementation.
Look at: Redis Pub/Sub | Docs

So, you have to know on which channels the info you need is published.
Then entering abc efg (if abc and efg are the channels) should work.

In my case, I never enter the topic in the box of the node.

I create a msg.topic in a previous node and in this case the syntax is ["abc","efg"]
Don't ask me why...

Thanks a lot. Definitely appreciate your help.

When you say that, I guess that's when you use a redis out node , not redis IN?

I'll make further investigation with maybe help of wireshark, I've seen there is a REDIS dissector available, maybe it will give me some useful information, in addition to the docs here and there....

Cheers

I always use the redis command.

Not sure what is the difference in your situation. In mine, command is working for everything...

Hi, was able to make some progress, I found the channels on which I want to subscribe with help of Redis Insight software

image

I ofught a bit with the Redis In node, actually when I want to subscribe to several channel from a single node, by entering different channel names separated by space, it does not work, I need to use a single channel in each node to get the messages correctly :

Would you mind sharing a little bit of your flow, to see if I can optimize the way I get messages, so I don't need a node for each of the channels ?

Thanks !

In a change node :

Screenshot 2024-04-30 at 10.55.34

then, this node connected to a redis command doing the SUBSCRIBE

It might also be necessary to delete, in that same change node, msg.payload.

1 Like

Thanks, will check

I see you are using the JSONata interpreter to build an array of static strings in your msg.topic field -- which is less efficient than just using the JSON {} mode:
(the J: evaluator is fairly heavyweight, although the output will be the same)

image

Of course, if the array will be built from other dynamic values like msg properties or context vars, then JSONata is the right choice...

1 Like