Google Appengine: My SQL Communications Link Failure from App Engine - google-app-engine

I have a Spring boot application connecting to gcloud sql (mysql) it works fine with public IP from my local machine, however when i deploy the app using appengine:deploy, it gives me a Communication link failure, I guess i am doing something wrong with my configuration.
I have allowed appengine service account with role cloud sql client.
and my configuration is
spring:
datasource:
url: jdbc:mysql://<PUBLIC IP>:3306/<DBNAME>
username: rsadmin
password: XXXXXX
spring.cloud.gcp.sql.database-name: <MYDBNAME>
spring.cloud.gcp.sql.instance-connection-name: <MYPROJECTID>:us-central1:<DBNAME>
Any helping would be highly appreciated
Thanks

Related

Unable to connect to Cloud SQL from sails mysql

I have a sails js app running on App Engine and a Cloud SQL instance that App Engine is supposed to talk to. I am using the following configuration with Sails v1.0 app:
adapter: 'sails-mysql',
socketPath: `/cloudsql/${process.env.INSTANCE_CONNECTION_NAME}`,
user: process.env.SQL_USER,
password: process.env.SQL_PASSWORD,
database: 'parsley'
All of the env variables are passed correctly but I still get this error:
name=AdapterError, adapterMethodName=create, modelIdentity=admin, name=Exception, code=badConnection, exit=badConnection, errno=ECONNREFUSED, code=ECONNREFUSED
If you are testing the code using the Cloud Shell and using a Cloud SQL Proxy:
Start the Cloud SQL Proxy in a Cloud Shell tab and leave the tab opened
Open a new tab. Try to connect from App Engine to Cloud SQL.
As described here:
Your application communicates with the proxy with the standard
database protocol used by your database. The proxy uses a secure
tunnel to communicate with its companion process running on the
server.
If you don't leave the Cloud SQL Proxy running in a tab, the secure tunnel is not created and is not possible to access Cloud SQL.
There are other issues that can cause this problem but according to the research I did "googling" the error, this looks like the most common.

Cannot connect to cloud SQL [SQLSTATE[HY000] [2002] No such file or directory]

I have set up 2 projects in my Google Cloud console. The following are the two projects that I have set up in my console.
1. Cloud SQL + App Engine
2. App Engine (New)
So the idea is App Engine (1) is running the same database as App Engine (2). I have already set up the IAM Permission Page and IAM Admin and Project Page.
I have given both projects as Project Editor role too, but still my (2) still can't connect to my (1) database.
Any help please?
Granting access to an application does not automatically enable a database user account to connect to the instance.
You may connect through a proxy, in which case you should follow these steps:
Enable the API
Install the proxy client on your local machine
Determine how you will authenticate the proxy
If required by your authentication method, create a service account
Determine how you will specify your instances for the proxy
Start the proxy
Update your application to connect to Cloud SQL using the proxy
You can find related details on the Connecting to Cloud SQL from External Applications.
This documents provides steps that cover configuring access for IP connections as well.
If you connect from within the app engine environment, you may have a look at Connecting from App Engine.

Why am I unable to connect to the Google Cloud SQL from Google App Engine?

I have a Google Cloud SQL project : cwdataproject (Project ID). I have created a schema named cwdb in it. Its Instance ID is : cwdataproject:cwinstance
I have provided access and privilege to cwdb for root user "root"
I have another app Google App Engine : messageframework (Project ID)
Project ID: messageframework
I have provided Authorized App Engine Applications in cwdataproject for messageframework
I have provided Authorized Networks for my local IP. and I am able to connect from local My SQL client successfully.
My code to connect Google Cloud SQL from messageframework app is as below.
Code:
Class.forName("com.mysql.jdbc.GoogleDriver");
url = "jdbc:google:mysql://cwdataproject:cwinstance/cwdb?user=ajoysinha;
DriverManager.getConnection(url);
But is is giving the following error
Access denied for user 'root'#'localhost' (using password: NO)
How can we resolve this connectivity problem?
I am able to connect Cloud SQL from my local MySql client and do all the operation. but not from GAE.

herokuapp subdomain not shown externally

I have a Facebook app running on Heroku. The app has been created directly from the Facebook app creation wizard. The subdomain is like myapp.herokuapp.com. The problem is when I connect to an external MySQL DB, another subdomain (amazonaws) is presented to the MySQL server. This is the answer of MySQL server, which does not grant access because of unknown domain.
Could not connect: Access denied for user 'mauro_wrdp2'#'ec2-23-22-65-197.compute-1.amazonaws.com' (using password: YES)
What do I need to do to have herokuapp subdomain presented instead on Amazon AWS?
You can't connect through your Herokuapp domain to your AWS instance - Postgres (not Mysql) runs separately to the applications which is why you have to connect directly to the AWS instance. I guess you would be free to CNAME your own domain to the AWS address but you run the risk of the DB being moved - Heroku would update the DATABASE_URL config variable on your behalf if this happened.

Google Cloud SQL configuration - get OAuth 2 token via GoogleCL for SQL or Eclipse

Configuring Google Cloud SQL to work with an app built using GWT Eclipse EE Plugin and am having authentication issues.
Google Command Line Tool - try running ./google_sql.sh instance
Need guidance setting up GoogleCL for CloudSQL. I installed regular GoogleCL using MacPorts. What next? I tried:
echo 'export PATH=Applications/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.0/appengine-java-sdk-1.7.0/bin/:$PATH' >> ~/.profile
ECLIPSE
Eclipse asks for Instance Name and Database name in two separate fields. I've tried every permutation of Project ID:database name (e.g. petproject:dog).
Here is the Eclipse error report (its the same every time):
Could not connect to Profile (name-of-the-project-in-Eclipse.GoogleCloudSQL.DevInstance).
Error creating SQL Model Connection connection to Profile (name-of-the-project-in-Eclipse.GoogleCloudSQL.DevInstance). (Error: Access denied for user 'my-login-id'#'localhost' (using password: YES))
Access denied for user 'my-login-id'#'localhost' (using password: YES)
Error creating Google Cloud SQL Connection factory connection to Profile (pse:
Could not connect to Profile (name-of-the-project-in-Eclipse.GoogleCloudSQL.DevInstance). (Error: Access denied for user 'my-login-id'#'localhost' (using password: YES))
Other
I can get a test app to work just fine. I have the test app running through a domain that I own. I've created a Google Cloud SQL project and instance. I've given permission for my app to use the instance on the Google API console. I have local mysql running and created the database/schema on my machine. I can't link up my local database to the GWT because the entire Google Cloud SQL needs to function.
Thanks -- very much appreciated.

Resources