redis / redis/node-redis

Changing host/port on an existing client for reconnection

Open
#1,363 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
TypeScript
Stars
17.6k
Forks
2k
Avg merge
2d 3h
Merged PRs (30d)
40

Description

A feature request: give the ability to update the connection settings of an existing client in place, so that it can reconnect to a different host if necessary after creation. For connections that stay open a long time, sometimes the remote Redis host gets redeployed on a new server, and it would be nice to be able to use a shared client and update it.

e.g.

const client = redis.createClient({ host: "1.2.3.4"  });
client.on("reconnecting", function() {
  // oops, the host has moved since a week ago
  client.setOptions({ host: "5.6.7.8" });
});

I'd imagine that calling .setOptions() on a connected client would also force a disconnect/reconnect.

Does this make sense? Is there a workaround to do this already that I'm missing?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the client creation, connection-options, and reconnecting entry points illustrated by createClient, setOptions, and the reconnecting event. Determine the intended behavior for changing host or port on a connected client, including whether it forces reconnection; the issue names no files or tests, so add coverage for the agreed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, redis, typescript
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.