fastify / fastify-redis

Plugin to share a common Redis connection across Fastify.
MIT License
198 stars 31 forks source link

connects to localhost irrespective of provided host #180

Closed laryhills closed 1 year ago

laryhills commented 1 year ago

Prerequisites

Fastify version

4.12.0

Plugin version

6.1.1

Node.js version

16.15.0

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

Venturay

Description

The plugin always tries to connect to localhost irrespective of the provided host

Steps to Reproduce

Using this connection snippet

app
    .register(fastifyRedis, {
      host: REDISHOST,
      password: REDISPASSWORD,
      port: REDISPORT,
      family: 4,
      namespace: "redis-info-1",
      closeClient: true,
    })
    .register(fastifyRedis, {
      namespace: "redis-info-2",
    });

Expected Behavior

Connect to provided host (REDISHOST) instead of localhost

mcollina commented 1 year ago

Those paramenters are passed straight into ioredis: https://github.com/fastify/fastify-redis/blob/ecb062253111a9fba2fece91418b27787f4de063/index.js#L56.

I don't think there is much we can do on this one, I feel you might have something odd happening in your application.

laryhills commented 1 year ago

I have sorted it out about 10 hours ago, got busy,

app
    .register(fastifyRedis, {
      host: REDISHOST,
      password: REDISPASSWORD,
      port: REDISPORT,
      family: 4,
      namespace: "redis-info-1",
      closeClient: true,
    })
    .register(fastifyRedis, {host: REDISHOST,
      password: REDISPASSWORD,
      port: REDISPORT,
      family: 4,
      closeClient: true,
      namespace: "redis-info-2",
    });

checked the index.js file and saw it need the connection for each namespace