# Someone with experience with REDIS subscribing?

**URL:** <https://discourse.nodered.org/t/someone-with-experience-with-redis-subscribing/87561>\
**Category:** General\
**Created:** [28 April 2024 11:12 UTC](https://discourse.nodered.org/t/someone-with-experience-with-redis-subscribing/87561 "2024-04-28T11:12:22Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeromeVISUALS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jeromevisuals/32/40103_2.png) [@JeromeVISUALS](https://discourse.nodered.org/u/JeromeVISUALS)\
**Post date:** [28 April 2024 11:12 UTC](https://discourse.nodered.org/t/someone-with-experience-with-redis-subscribing/87561/1 "2024-04-28T11:12:22Z")

</div>

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](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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/d/6dd28228085e8772716089648e221dcfd251d086.png)

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

Thanks !

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 April 2024 11:21 UTC](https://discourse.nodered.org/t/someone-with-experience-with-redis-subscribing/87561/2 "2024-04-28T11:21:21Z")

</div>

> [@JeromeVISUALS](#):
>
> Error: connect ECONNREFUSED 127.0.0.1:6379

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?

---

<div class="post-metadata">

**Author:** ![JeromeVISUALS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jeromevisuals/32/40103_2.png) [@JeromeVISUALS](https://discourse.nodered.org/u/JeromeVISUALS)\
**Post date:** [28 April 2024 18:40 UTC](https://discourse.nodered.org/t/someone-with-experience-with-redis-subscribing/87561/3 "2024-04-28T18:40:27Z")

</div>

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 !

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [28 April 2024 19:26 UTC](https://discourse.nodered.org/t/someone-with-experience-with-redis-subscribing/87561/4 "2024-04-28T19:26:38Z")

</div>

> [@JeromeVISUALS](#):
>
> So for my understanding, every devices interested in REDIS messages have to run a REDIS server ?

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)

---

<div class="post-metadata">

**Author:** ![JeromeVISUALS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jeromevisuals/32/40103_2.png) [@JeromeVISUALS](https://discourse.nodered.org/u/JeromeVISUALS)\
**Post date:** [29 April 2024 16:17 UTC](https://discourse.nodered.org/t/someone-with-experience-with-redis-subscribing/87561/5 "2024-04-29T16:17:06Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/1/f11c16ade9e3ff8113a04875a635f8a52b752d62.png)

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 ....

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/8/a867948e233e952c2a54ee37d553e96a52f1b620.png)

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [29 April 2024 17:32 UTC](https://discourse.nodered.org/t/someone-with-experience-with-redis-subscribing/87561/6 "2024-04-29T17:32:12Z")

</div>

> [@JeromeVISUALS](#):
>
> 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._

Told you. Challenging documentation.

If often used the [redis.io](http://redis.io) documentation and "translate" for this implementation.  
Look at: [Redis Pub/Sub | Docs](https://redis.io/docs/latest/develop/interact/pubsub/)

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...

---

<div class="post-metadata">

**Author:** ![JeromeVISUALS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jeromevisuals/32/40103_2.png) [@JeromeVISUALS](https://discourse.nodered.org/u/JeromeVISUALS)\
**Post date:** [29 April 2024 19:23 UTC](https://discourse.nodered.org/t/someone-with-experience-with-redis-subscribing/87561/7 "2024-04-29T19:23:38Z")

</div>

Thanks a lot. Definitely appreciate your help.

> [@greengolfer](#):
>
> I create a msg.topic in a previous node and in this case the syntax is `["abc","efg"]`  
> Don't ask me why...

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

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [29 April 2024 20:50 UTC](https://discourse.nodered.org/t/someone-with-experience-with-redis-subscribing/87561/8 "2024-04-29T20:50:35Z")

</div>

I always use the redis command.

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

---

<div class="post-metadata">

**Author:** ![JeromeVISUALS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jeromevisuals/32/40103_2.png) [@JeromeVISUALS](https://discourse.nodered.org/u/JeromeVISUALS)\
**Post date:** [30 April 2024 08:23 UTC](https://discourse.nodered.org/t/someone-with-experience-with-redis-subscribing/87561/9 "2024-04-30T08:23:06Z")

</div>

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

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/4/f423058023bfce478fee1464edff5a75276c0fca.png)

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 :

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd80a6b295c11a8814304182cb618694a9d83270.png)

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 !

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [30 April 2024 08:57 UTC](https://discourse.nodered.org/t/someone-with-experience-with-redis-subscribing/87561/10 "2024-04-30T08:57:05Z")

</div>

In a change node :

![Screenshot 2024-04-30 at 10.55.34](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/7/7758808bb00149329a4d2b8d9849797552c22509.png)

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.

---

<div class="post-metadata">

**Author:** ![JeromeVISUALS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jeromevisuals/32/40103_2.png) [@JeromeVISUALS](https://discourse.nodered.org/u/JeromeVISUALS)\
**Post date:** [30 April 2024 09:07 UTC](https://discourse.nodered.org/t/someone-with-experience-with-redis-subscribing/87561/11 "2024-04-30T09:07:52Z")

</div>

Thanks, will check

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [30 April 2024 12:41 UTC](https://discourse.nodered.org/t/someone-with-experience-with-redis-subscribing/87561/12 "2024-04-30T12:41:19Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/0/e04edbe8e82a3e846ba3605e716c49fa6b51fa7b.png)

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [29 July 2024 12:42 UTC](https://discourse.nodered.org/t/someone-with-experience-with-redis-subscribing/87561/13 "2024-07-29T12:42:07Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
