2

When I tried to deploy AdonisJS to digital ocean or Azure, I get this error

[ioredis] Unhandled error event: Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:209:20)

My Adonis app requires Redis to run. I'm using a Redis instance from Digital Ocean. Here's my production config for Redis.

  prod: {
    host: Env.get("REDIS_HOST"),
    port: Env.get("REDIS_PORT"),
    password: Env.get("REDIS_PASSWORD"),
    db: 0,
    keyPrefix: ""
  },
Osinachi
  • 656
  • 8
  • 14
  • I'm seeing this as well with a local docker instance. Doesn't seem to happen when Redis is started without the --requirepass option. Do you know your redis-server startup options or redis.conf settings? Would be curious to compare notes. – hoekma Jan 24 '21 at 02:37

2 Answers2

3

If you are connecting your AdonisJS app to a Transport Layer Security (TLS) protected Redis instance, you need to add the tls host to your config.

So, your prod config should look like this

  prod: {
    host: Env.get("REDIS_HOST"),
    port: Env.get("REDIS_PORT"),
    password: Env.get("REDIS_PASSWORD"),
    db: 0,
    keyPrefix: "",
    tls: {
      host: Env.get("REDIS_HOST"),
    },
  },
Osinachi
  • 656
  • 8
  • 14
0

As a followup to my comment - my docker environment degraded to the point where I couldn't even connect via redis-cli to the vanilla dockerhub Redis image. I wound up cleaning out my docker environment by removing all containers, images, volumes, networks, etc., and then rebooting my mac. After rebuilding them this problem went away for me.

I hate not knowing the "root cause" but have a theory. I had been playing with a few different Redis images including the vanilla standalone image from dockerhub and a cluster image from https://github.com/Grokzen/docker-redis-cluster. I was tweaking the build of the latter to add authentication. The theory is that there were residual processes fighting over the port from repeated builds and tear downs. I may have been impatient and hard-stopped the containers I was working on multiple times while debugging the dockerfile and docker-entrypoint.sh files. :)

I know this answer isn't directly related to hosting on DO or Azure but since the symptom is the same, perhaps there is a networking conflict somewhere.

hoekma
  • 793
  • 9
  • 19