-1

I'm currently using Spring Boot version 3.1.0 along with GCP Memory Store, which serves as a Redis instance. However, I'm getting below exception while establishing a connection to Redis. I've attempted this connection using both a GCP Cloud Function and a Cloud Run Service.

    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)

Steps taken:

  • Added dependency as spring-boot-starter-data-redis along with spring-boot-starter-cache, lettuce-core.
  • Added dependency google-cloud-redis (instead of spring-boot-starter-data-redis).
  • Added VPC connector to connect with redis.
  • Added Configuration as below

I am trying to cache data and retrieve it from cache using Spring Boot version 3.1.0 along with GCP Memory Store, the connection should be established but it is unable.

Puteri
  • 3,348
  • 4
  • 12
  • 27
  • `google-cloud-redis` is only used to manage the instance, not to connect to it. Add the code you're using to connect and configurations in detail. You say you added a VPC connector but we don't know if you configure your function o CR service to use it. – Puteri Aug 22 '23 at 21:42
  • @Bean public RedisConfiguration defaultRedisConfig() { RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(); config.setHostName(host); config.setPort(port); config.setPassword(RedisPassword.of(password)); return config; } – Snigdha Dutta Aug 28 '23 at 08:04
  • Please add it to the question, not in a comment – Puteri Aug 28 '23 at 08:08

0 Answers0