Open matthias-hampel opened 6 months ago
I'm trying to deploy a web application (six Node.js applications and a Redis database) with Docker Swarm.
The web applications writing data into the Redis database and using ioredis.
ioredis
Once I deploy the Redis database on another node than the web applications are running, they cannot connect to Redis.
I already changed the Redis configuration and set the following properties (this is just an excerpt):
bind protected-mode no requirepass foobared0.0.0.0
The connection string should the look like this:
redis://default:foobared@redis:6379/1
I have checked it, by placing the web applications and Redis on the same machine, where then everything works fine.
But once I distribute the containers over all nodes, the web apps cannot connect to Redis. I created a network that is assigned to all services:
services: redis: image: redis:latest deploy: placement: constraints: [node.role == manager] networks: - redis command: redis-server /usr/local/etc/redis/redis.conf configs: - source: redis target: /usr/local/etc/redis/redis.conf ports: - 6379:6379 networks: redis: driver: overlay
One thing that might be important is, that I can reach the Redis host from the web app containers. I tested it by running:
ping redis It always gave me a response.
I also tried to connect with redis-cli from one of the containers which also worked fine:
root@5495c5a491bd:/app# redis-cli -h redis redis:6379> auth default foobared OK redis:6379> ping PONG redis:6379>
At this point, I think it could be a problem with ioredis but I am just not sure and I don't know where I can dig deeper to solve the problem.
I have the same issue
@victorcastro89 I couldn't find the issue and ended up switching to redis which works fine for me.
redis
I'm trying to deploy a web application (six Node.js applications and a Redis database) with Docker Swarm.
The web applications writing data into the Redis database and using
ioredis
.Once I deploy the Redis database on another node than the web applications are running, they cannot connect to Redis.
I already changed the Redis configuration and set the following properties (this is just an excerpt):
The connection string should the look like this:
I have checked it, by placing the web applications and Redis on the same machine, where then everything works fine.
But once I distribute the containers over all nodes, the web apps cannot connect to Redis. I created a network that is assigned to all services:
One thing that might be important is, that I can reach the Redis host from the web app containers. I tested it by running:
I also tried to connect with redis-cli from one of the containers which also worked fine:
At this point, I think it could be a problem with
ioredis
but I am just not sure and I don't know where I can dig deeper to solve the problem.