I am unable to connect to Google Cloud (GCP) Memory Instance - Redis instance (6.X or 7.X) using the IP and PORT from cloud run developed on Spring boot (3.1.0).
Below is the error:
From Cloud Run Response { "timestamp": "2023-08-27T06:46:48.837777718", "message": "Unable to connect to Redis", "statusCode": "INTERNAL_SERVER_ERROR" }
Below are the ways tried.
- Both the cloud run and Google managed Redis are created in same region. Try 1. Cloud Run is configured with the Server less VPC connector and Redis instance has been created. - Connection Type - Private Network access Try 2. Just Created Redis instance and on Memory store. - Connection Type - Direct Peering.
Below is the spring Boot Application Config
spring: data: redis: host: <MEMORY_STORE_REDIS_IP> port: 6378 cache: cache-names: - <CACHE_NAME_1> - <CACHE_NAME_2> redis: time-to-live: 60000
Below are the dependencies added:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.4.3</version>
</dependency>
Official documentation on Google Cloud has the details about using the Cloud Compute to use Redis. But we don't wanted it, we wanted GCP managed instance.