Cloud SQL from App Engine (flexible environment) c

2019-07-23 16:10发布

问题:

I'm trying to access my Cloud SQL instance from my App Engine flexible environment NodeJS application but kept getting timeout issues.

When I add the IP of the compute engine running the App engine to the Cloud SQL Access Control it works. The documentation states that access should be granted automatically if both are in the same project.

What am I missing?

I'm using the following connection settings for knex:

const config = {
    host: 'myIP',
    user: 'user',
    password: 'password',
    database: 'database',
    port: 3306
  };

The socket settings aren't working either. throwing a "Unhandled rejection Error: connect ENOENT /cloudsql" exception:

const config = {
    socketPath: '/cloudsql/project:zone:instance',
    user: 'user',
    password: 'password',
    database: 'database'
  };

回答1:

This error most likely indicates that the proxy process is not running on the GAE Flexible instance.

As per the documentation, you must have cloud_sql_instances set in your app.yaml file for the proxy to be automatically started.