From 2d03b6d39ed6b4def3cda89dc6762166c564b650 Mon Sep 17 00:00:00 2001 From: sundeep8967 Date: Sat, 7 Nov 2026 20:37:11 +0530 Subject: [PATCH] fix(query-redis-labs): support configurable REDIS_PORT Previously the Redis socket connection hardcoded port 14714. Redis Cloud assigns dynamic ports per created database, preventing instances from connecting when deployed outside port 14714. Allow configuring REDIS_PORT via environment variable with fallback to 14714 for backward compatibility. Document the variable in README. Fixes #490 Signed-off-by: sundeep8967 --- node/query-redis-labs/README.md | 9 +++++++++ node/query-redis-labs/src/redis.js | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/node/query-redis-labs/README.md b/node/query-redis-labs/README.md index 80494283..f2eea549 100644 --- a/node/query-redis-labs/README.md +++ b/node/query-redis-labs/README.md @@ -48,3 +48,12 @@ Authentication password to access your Redis database. | ------------ | ------------------------------ | | Required | Yes | | Sample Value | `efNNehiACfcZiwsTAjcK6xiwPyu6Dpdq` | + +### REDIS_PORT + +The port on which your Redis database is listening. + +| Question | Answer | +| ------------ | ------------------------------ | +| Required | No (Defaults to `14714`) | +| Sample Value | `14714` | diff --git a/node/query-redis-labs/src/redis.js b/node/query-redis-labs/src/redis.js index 260e3a0d..1a212c11 100644 --- a/node/query-redis-labs/src/redis.js +++ b/node/query-redis-labs/src/redis.js @@ -5,13 +5,13 @@ import { createHash } from 'node:crypto'; * Throws an error if any of the keys are missing from the object */ export async function getClient() { - const { REDIS_PASSWORD, REDIS_HOST } = process.env; + const { REDIS_PASSWORD, REDIS_HOST, REDIS_PORT } = process.env; const client = createClient({ password: REDIS_PASSWORD, socket: { host: REDIS_HOST, - port: 14714 + port: REDIS_PORT ? parseInt(REDIS_PORT, 10) : 14714 } });