2
votes

I'm currently trying to connect my App Engine node.js service to a Google Cloud Memorystore. Following this guide, I need both to run in the same network and region (in my case Europe). This seems impossible since I can only create the Redis instance in europe-west-1 or europe-west-4, while App Engine offers me europe-west, europe-west-2 or europe-west-3.

I'm assuming 'same region' stands for europe-west-x ? If this is true, I'm still unable to connect, configuring the Node.js on the IP X.X.X.X:XXXX as described in the gcloud console (for my active Redis instance) the app throws connection failed, ETIMEDOUT.

Is the region the reason?

The instance has the authorized network set to default and the apps app.yaml has:

network: name: default

UPDATE:

Even when i have GAE in europe-west-1 and Memorystor in europe-west as suggested i get

Redis connection to X.X.X.X:XXXX failed - connect ETIMEDOUT X.X.X.X:XXXX

I'm using node_redis with the following code fragment to test the connection (REDIS_PORT and REDIS_IP are the values i see on the Memorystore instance page):

const redis = require('redis'); 
let redisClient = redis.createClient(REDIS_PORT, REDIS_IP);

redisClient.set("string key", "string val", redis.print);
redisClient.hset("hash key", "hashtest 1", "some value", redis.print);
redisClient.hset(["hash key", "hashtest 2", "some other value"], redis.print);
redisClient.hkeys("hash key", function (err, replies) {
    console.log(replies.length + " replies:");
    replies.forEach(function (reply, i) {
        console.log("    " + i + ": " + reply);
    });
    redisClient.quit();
});
redisClient.on("error", function (err) {
    console.log("Redis rror " + err);
});
3

3 Answers

2
votes

Regions are specific geographical locations, and each region has different zones (or just one). For example, europe-west1-b and europe-west1-c are the same region (europe-west1) but different zone (b or c).

Also, europe-west1 and europe-west2 are different regions the same way europe-west1 and us-central1 are.

Regarding your issue, europe-west is the same as europe-west1, so you should choose that for connecting GAE to Memorystore. If you choose two different "numbers" for regions, as they are different regions, you won't be able to connect.

Here is a piece of documentation that explains "Regions and zones":

  • Regions are collections of zones. Zones have high-bandwidth, low-latency network connections to other zones in the same region. [...]
  • A zone is an isolated location within a region. The fully-qualified name for a zone is made up of region-zone. [...]
2
votes

I realized the GAE service has to run in the flex environment, so the application is based on Google Compute Engine aswell. The env: flex was missing in the app.yaml. The communication between GAE and Memorystore is working with this configuration.

0
votes

I'm having exactly the same issue, even that I have env: flex in my app.yaml, but it still gives me ETIMEDOUT.

As by the docs, I had to configure a VPC connector and pass it to vpc_access_connector in the app.yaml, which still does not work.

Did you have to do the same, or does it work without the VPC connector?