【问题标题】:Random SSL handshake error when connecting to ElastiCache with ioRedis使用 ioRedis 连接到 ElastiCache 时出现随机 SSL 握手错误
【发布时间】:2019-02-25 05:13:36
【问题描述】:

我正在尝试使用 ioRedis 从节点脚本连接到在传输过程中加密的 ElastiCache 集群。有时我的脚本有效,有时我得到Error: 140736319218624:error:140940E5:SSL routines:ssl3_read_bytes:ssl handshake failure:../deps/openssl/openssl/ssl/s3_pkt.c:1216:

这是我所有的代码:

var Redis = require('ioredis');
var nodes = [{
host: 'clustercfg.name.xxxxxx.region.cache.amazonaws.com',
port: '6379',
}];
var cluster = new Redis.Cluster(nodes,{
redisOptions: {
    tls: {}
}});

cluster.set('aws', 'test');
cluster.get('aws', function (err, res) {
    console.log(res);
    if (err) {
        console.error(err)
    }
    cluster.disconnect()
});

【问题讨论】:

  • “ssl 握手失败”可能是很多事情。如果双方没有更多的日志记录,将很难进行调试。可能是主机名有时会解析为不同的 IP 地址,而您访问的是不同的服务器?
  • 对方是AWS托管的ElastiCache服务,所以我无权访问对方的ssl配置。

标签: node.js ssl redis amazon-elasticache ioredis


【解决方案1】:

我认为 ssl 握手错误是 ioredis 中竞争条件错误的副作用。

过去几天我一直在为同一个问题(ioredis 版本 4.0.0)苦苦思索。我只是无法可靠地将 ioredis 连接到我们的 elasticache 集群。我会看到同样的间歇性错误。

错误:140618195700616:错误:140940E5:SSL 例程:ssl3_read_bytes:ssl 握手失败:../deps/openssl/openssl/ssl/s3_pkt.c:1216:

您可以通过在节点环境中设置“DEBUG=ioredis:*”来查看 ioredis 调试输出。一旦我这样做了,我可以看到当错误发生时它伴随着几条类似于以下的消息:

2018-10-06T18:24:38.287Z ioredis:cluster:connectionPool 断开连接 xxx.usw2.cache.amazonaws.com:6379 因为该节点不持有任何 插槽

我尝试了 node-redis 和 redis-clustr,它与 elasticache 配合得很好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-28
    • 2018-10-12
    • 2023-04-02
    • 1970-01-01
    • 2012-06-02
    • 1970-01-01
    • 2014-12-16
    • 1970-01-01
    相关资源
    最近更新 更多