Help Needed: Redis + Caprover + Wappler

Thanks to the discussion on the post around making NodeJS app scalable (Make scalable NodeJS app in Wappler without special knowledge) & @JonL, I discovered that using Redis in Wappler with Caprover based-deployment is possible.

Unfortunately, I am getting connection timeout on Wappler after setting https://IP:port OR redis://IP:port from my web-exposed Caprover Redis app.
My target on Wappler is a simple local server (not the Wappler one).

Maybe I need to set the password somewhere, but can’t figure out where. Or will it not work on localhost, only when deployed?

Please help.

Not sure how Caprover works - but if Redis is also deployed with docker, you need to supply as redis connection, the docker internal service name for redis and not the external IP address

1 Like

Connection string format is redis[s]://[[username][:password]@][host][:port][/db-number].

You need to use the container name as host, something like: redis://srv-captain--redis.

2 Likes

@sid while you are at it can you through there an SC binding for an ENV variable to test that out.

Before 4.9.0 it wasn’t possible but it should be now.

But that will not work in localhost.
The make it work in localhost, it would have to be something like:
redis://:password@192.x.x.x:port
I don't know what the username should be either.

Tried 4.9.0 on sandbox machine, no picker here.

image

How are you running redis on your local machine? Docker? Standard Wappler setup?

I have no setup for Redis on my local machine.
I just see some packages added to the project when I enable Redis in Wappler, but nothing else.

Do I need to install Redis on my local machine? Wouldn’t the remote server redis work?

Yes it would, but as you asked specifically for redis on localhost. When Wappler creates a redis instance via docker on your local machine it binds the redis as the name of the machine.

That's is why by default the connection string is redis://redis

I got back at the computer and I was able to test it.

I confirm it works. You can now add moustache notation to include a SC binding.

Previous to 4.9.0 this wouldn't work.

image

Now it does. @George this one is missing the picker icon.

So that data is written/read from app/config/config.json

image

And Patrick recently added

Parser.parseValue(config, new Scope({ 
    $_ENV: process.env 
})); 

To the config.js logic to parse the data which previously was just static.

This means that app/config/config.json and app/config/user_config.json are now parseable. More about the latter here:

Ok. Sort of making sense.
So why isn’t the local machine able to connect to the remote Caprover Redis instance?
Tried the connection string Patrick suggested, but I don’t know username, just the password.

The connection string that @patrick gave you will only work for apps that belong to the same docker swarm. This is the one created by caprover. Any app created in your caprover instance can connect to each other using the internal hostname.

If you want to connect to that same redis instance from outside(your computer here) you need to map a port.

Once you have mapped a port then you will be able to connect externally via the remote machine ip and mapped port.

1 Like

Damn. I have used that before for the DB we have hosted. Never occured to try it here.
Thanks. One step closer.

I’ve set the connection string like so:

redis://password@x.x.x.x:port

Now how do I confirm if a page is being served from Redis cache?

1 Like

It works! :smiley:
Thanks for all the help.

One more question:
How to invalidate a particular cache?
It could be anything - sockets, content page, SA etc - whatever is cacheable.

I read these two posts regarding it: Redis cache confusion & Redis cache upgrades but could not make sense of it much.