How to configure ElastiCache Redis for Spring data access

I am trying to configure ElastiCache for use with a Java application. I based my setup based on this documentation: https://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/BestPractices.html

The EC2 instance in which the Java application (8) is running is located in the VPC. I tried an instance of ElastiCache in both VPC and VPC. However, I always got

redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused

If I install Redis myself on an EC2 instance and connect to it, the application can connect to Redis Cache!

I set the correct authorization with the security group from EC2 to Cache-Security, but no luck. I just can't make a “connection”. Any fragment of an example compound will be really helpful.

Redis is configured this way in the APP configuration:

    @Bean
    public JedisConnectionFactory redisConnectionFactory() {
    JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
    redisConnectionFactory.setHostName(<cache-node>);
    redisConnectionFactory.setPort(6397);
    redisConnectionFactory.setUsePool(true);
    redisConnectionFactory.setTimeout(3600);
    return redisConnectionFactory;
   }

Different versions:

Jedis- 2.6.2, Spring- 4.1.6, Spring-data-> 1.5.0
+4
source share
1 answer
redisConnectionFactory.setPort(6397);

it should be

redisConnectionFactory.setPort(6379); //default redis port
0
source

All Articles