Random SSL handshake error when connecting to ElastiCache with ioRedis

Viewed 1079

I am attempting to connect to an ElastiCache cluster that is encrypted in transit from a node script using ioRedis. Sometimes my script works, other times I get Error: 140736319218624:error:140940E5:SSL routines:ssl3_read_bytes:ssl handshake failure:../deps/openssl/openssl/ssl/s3_pkt.c:1216:

Here is all of my code:

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()
});
1 Answers

I believe the ssl handshake error is a side-effect of a race-condition bug in ioredis.

I have been banging my head over the same issue the last several days (ioredis version 4.0.0). I just couldn't reliably connect ioredis to our elasticache cluster. I would see the same intermittent error.

Error: 140618195700616:error:140940E5:SSL routines:ssl3_read_bytes:ssl handshake failure:../deps/openssl/openssl/ssl/s3_pkt.c:1216:

You can view ioredis debug output by setting "DEBUG=ioredis:*" in your node environment. Once I did this I could see that when the error occurred it was accompanied by several messages similar to the following:

2018-10-06T18:24:38.287Z ioredis:cluster:connectionPool Disconnect xxx.usw2.cache.amazonaws.com:6379 because the node does not hold any slot

I tried node-redis and redis-clustr it works fine with elasticache.

Related