Hello, I'm currently utilizing Spring Boot version 3.1.0 along with GCP Memory Store, which serves as a Redis instance. However, I'm encountering difficulties in establishing a connection to Redis, resulting in the following error. I've attempted this connection using both a GCP Cloud Function and a Cloud Run Service..

I have tried spring-boot-starter-data-redis along with spring-boot-starter-cache,lettuce-core also I have used google-cloud-redis but facing same issue using both

Error Details: Exception: org.springframework.data.redis.RedisConnectionFailureException Message: Unable to establish a connection to Redis Root Cause:

io.lettuce.core.RedisConnectionException - Unable to connect to XX.XX.XXX.XXX/<unresolved>:6378

org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.translateException(LettuceConnectionFactory.java:1604)
org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1360)
org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:1343)
org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getSharedConnection(LettuceConnectionFactory.java:1061)
org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getConnection(LettuceConnectionFactory.java:400)
org.springframework.data.redis.cache.DefaultRedisCacheWriter.execute(DefaultRedisCacheWriter.java:272)
org.springframework.data.redis.cache.DefaultRedisCacheWriter.get(DefaultRedisCacheWriter.java:122)
org.springframework.data.redis.cache.RedisCache.lookup(RedisCache.java:167)
org.springframework.cache.support.AbstractValueAdaptingCache.get(AbstractValueAdaptingCache.java:58)

Redis Config :

    @Configuration
    @ConfigurationProperties(prefix = "spring.data.redis")
    @Setter
    public class RedisConfig {

        private String host;
        private String password;
        private int port;

        @Bean
        @Primary
        public ReactiveRedisConnectionFactory reactiveRedisConnectionFactory(RedisConfiguration defaultRedisConfig) {
            LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder()
                    .useSsl().and()
                    .commandTimeout(Duration.ofMillis(60000)).build();
            return new LettuceConnectionFactory(defaultRedisConfig, clientConfig);
        }

        @Bean
        public RedisConfiguration defaultRedisConfig() {
            RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
            config.setHostName(host);
            config.setPort(port);
            config.setPassword(RedisPassword.of(password));
            return config;
        }
    }

Comment From: scottfrederick

Thanks for getting in touch. It is not clear what role Spring Boot has in the issue you are having. The exception is coming from Spring Data Redis, which is managed as a separate project from Spring Boot. The problem appears to happen whether you are using the Spring Boot starters or the GCP support libraries. By declaring your own ReactiveRedisConnectionFactory in a @Configuration class, you are causing any Spring Boot auto-configuration to back off.

Given the uncertainty about where your problem lies, this feels like a question that would be better suited to Stack Overflow so that the right people can help. Please post the question there, preferably with a minimal sample application that demonstrates the problem. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.

Comment From: iamshe

without the configuration class as well I am facing the same issue. Spring Boot 3.1.0 with spring -data -redis or google-cloud-redis unable to connect with GCP Memory store