我的 Kubernetes 集群上的 AWS redis 连接错误

问题描述

我想在 AWS 上使用 Redis。 我的开发环境依赖于带有 Kubernetes 的 Skaffold。

我的安全组配置是:

Inbound rules

Outbound rules

我的 Redis 配置是这样的:

Redis config

我想在我的 nodeJS 应用程序上从 Kubernetes pod 连接这个 Redis 所以,我的代码是这样剪的:

let statsQueue = new Queue('statistics','<Primary-Endpoint-On-AWS-Redis');

但我收到此错误

         triggeruncaughtException(err,true /* fromPromise */);
          ^

Error: connect EINVAL 0.0.24.235:6379 - Local (0.0.0.0:0)
    at internalConnect (node:net:909:16)
    at defaultTriggerAsyncIdScope (node:internal/async_hooks:431:12)
    at GetAddrInfoReqWrap.emitLookup [as callback] (node:net:1055:9)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:8) {
  errno: -22,code: 'EINVAL',syscall: 'connect',address: '0.0.24.235',port: 6379
}

为什么我会收到这个错误?我该如何解决这个问题?

解决方法

通过从 URL 添加 Redis:// 解决了错误。

这样的连接: let statsQueue = new Queue('statistics','Redis://