0
我正在嘗試使用spring-data-redis將AWS elasticache redis與Spring啓動應用程序集成。使用服務時獲得以下例外。來自Spring Boot App的AWS Redis集羣連接問題
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:191)
... 84 more
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused
at redis.clients.jedis.Connection.connect(Connection.java:164)
使用下面的代碼
@Bean
public RedisConnectionFactory jedisConnectionFactory(JedisPoolConfig jedisPoolConfig) {
JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory(jedisPoolConfig);
redisConnectionFactory.setHostName("AWS primary replication group endpoint");
redisConnectionFactory.setPort(6379);
redisConnectionFactory.setUsePool(true);
redisConnectionFactory.setTimeout(3600);
return redisConnectionFactory;
}
我能夠在服務被部署到從我的EC2實例連接到AWS Redis的。任何示例代碼或步驟都會非常有用。
您可以使用'redis-cli'成功連接到服務器嗎? – mp911de
是的,我可以從redis-cli連接 – user3319797