Skip to content
This repository was archived by the owner on Aug 17, 2023. It is now read-only.
This repository was archived by the owner on Aug 17, 2023. It is now read-only.

Client is not reconnecting to hosts that go down and come back up #27

@justinhelmer

Description

@justinhelmer

We are using thunk-redis because it is the only node client that we found that accepts multiple hosts (i.e. primary/replica), without Sentinel or Clustering. We are using AWS Elasticache.

When one host goes down, the client correctly responds with data from the other host. However, when the host goes back up, the client does not reconnect to the first host or start serving from the primary.

To replicate, launch redis on two hosts (in my case, launching locally on two separate ports), then run the following:

const redis = require('thunk-redis');

client = redis.createClient(['127.0.0.1:6379', '127.0.0.1:6380'], { clusterMode: false, usePromise: true });

client.set('key', 'value').then(getKeyEverySecond);

function getKeyEverySecond() {
  const int = setInterval(async () => {
    try {
      console.log(await client.get('key'));
    } catch (err) {
      clearInterval(int);
      throw err;
    }
  }, 1000);
}

Kill one server. You will see the client correctly starts reading from the other server (regardless of which you kill). Then restart the server, immediately. Once running, kill the other server.

You will see:

Error: The redis client was ended

My expectation is that as soon as the first (primary) host goes back up, the client will internally have reconnected to it, and will start serving from it again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions