cloud sql unable to connect to app engine during deployment - google-app-engine

App Engine : Flexible
CloudSQL : 2nd Gen
Framework : Node.js
Node lib: mysql
I am seeing this error after I deploy :
2016/10/29 11:38:03 listenInstance: "santex-1101:asia-east1:santexdb"
2016/10/29 11:38:03 Remove("/cloudsql/santex-1101:asia-east1:santexdb") error: remove /cloudsql/santex-1101:asia-east1:santexdb: no such file or directory
2016/10/29 11:38:03 Open socket for "santex-1101:asia-east1:santexdb" at "/cloudsql/santex-1101:asia-east1:santexdb"
2016/10/29 11:38:03 Socket prefix: /cloudsql
2016/10/29 11:39:20 listenInstance: "santex-1101:asia-east1:santexdb"
2016/10/29 11:39:20 Remove("/cloudsql/santex-1101:asia-east1:santexdb") error: remove /cloudsql/santex-1101:asia-east1:santexdb: no such file or directory
2016/10/29 11:39:20 Open socket for "santex-1101:asia-east1:santexdb" at "/cloudsql/santex-1101:asia-east1:santexdb"
2016/10/29 11:39:20 Socket prefix: /cloudsql
app.js :
var pool = mysql.createPool({
connectionLimit: 100,
multipleStatements: true,
user: config.get('MYSQL_USER'),
password: config.get('MYSQL_PASSWORD'),
database: config.get('MYSQL_DATABASE'),
socketPath: "/cloudsql/santex-1101:asia-east1:santexdb"
});
app.yaml :
runtime: nodejs
vm: true
beta_settings:
cloud_sql_instances: "santex-1101:asia-east1:santexdb"
I am not sure what is causing this problem.
I also did ssh into the vm to check and I can see that /cloudsql/santex-1101:asia-east1:santexdb is existing.
Please help
Thanks in advance,
timecatcher

Related

ERROR: (gcloud.app.deploy) Error Response: [13] Failed to create manifest file

I am trying to deploy a Flask app on Google Cloud Engine and I get the following error:
ERROR: (gcloud.app.deploy) Error Response: [13] Failed to create manifest file.
I created a new project but the problem persist. I am able to deploy example Flask app. I don't understand what problem this specific app has. Here are the details:
This is my app.yaml
runtime: python37
env_variables:
CLOUD_SQL_PASSWORD : ""
CLOUD_SQL_CONNECTION_NAME : ""
CLOUD_SQL_USERNAME : "postgres"
CLOUD_SQL_DATABASE_NAME : "postgres"
And this is what I have in my folder
.
..
.DS_Store
.gcloudignore
.git
.gitignore
.mypy_cache
.swp
README.md
app.yaml
client
flaskr
gcskey.json
instance
main.py
requirements.txt
tests
venv
and is is my .gcloudignore
venv
gcpkey.json
gcskey.json

Cloud SQL from App Engine (flexible environment) connection issue

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'
};
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.

How to solve this SQLSTATE[HY000] [2002] no connection could be made because the target machine actively refused it

I am trying to follow an e-commerce tutorial where I have to create the connection with the database. I am on windows 7 with xampp v3.2.
So I use this : php bin/console generate:doctrine:entity
which gives me this error :
SQLSTATE[HY000] [2002] no connection could be made because the target
machine actively refused it
I closed xampp and I still had the same error. So I understand it comes from the configuration; somehow my shell doesn't communicate with my sql server from xampp.
here is my parameters.yml :
# This file is auto-generated during the composer install
parameters:
database_host: localhost
database_port: 3306
database_name: market
database_user: sebastian
database_password:
mailer_transport: smtp
mailer_host: localhost
mailer_user: null
mailer_password: null
secret:
and here my config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: "#EcommerceBundle/Resources/config/services.yml" }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
fragments: ~
http_method_override: true
assets: ~
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
I checked for the extension php_pdo_mysql.dl and it is enabled.
I verified the database name, user and password.
here is a netstat :
netstat
Make sure that your MySQL server is running and that it's using that port (in xampp\mysql\bin\my.ini). Make sure that you're able to connect manually with those credentials as well.
Also, where are you specifying the database driver in your parameters.yml? Normally you should have something like this:
database_driver: pdo_mysql
And lastly, make sure that you don't have a different parameters.yml file included in your config_dev.yml because Symfony commands, by default, use the dev environment.
thank you for your answer.
I have in my.ini 3306 port so it is the good one. I have intalled symfony2.8 and it is working so there is no credentials problems. I also tried to add the line with pdo_mysql but the error message is an pdo_exception, that means pdo works as well.
I also check config.dev but I don't really know what can be wrong inside. So I show you what it looks like :
imports:
- { resource: config.yml }
framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: [!event]
console:
type: console
channels: [!event, !doctrine]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
#swiftmailer:
# delivery_address: me#example.com
thank for your help
i cant connect to mysql on xamppp
install mysql 8 on my system on port 3307
and its worked great with laravel.
if you want please install mysql workbench (instead of phpmyadmin)

Connection refused on heroku using generator-sql-fullstack

you are my last chance here. So I've build a project with generator-sql-fullstack package and trying to deploy it to heroku.
Unfortunately, I can't connect to Heroku database as I get Error R10.
I've tried different ways to connect to postgres through sequelize - none of them worked. The main thing was to make it ssl compatible, but it still doesn't connect (or maybe I am using it wrong)
Project runs great locally, app is build without any errors also.
Please, take a look into Heroku logs and main files for connection. Hopefully, you will be able to help me here. Thank you.
$ heroku logs
2016-04-18T21:27:36.994697+00:00 app[web.1]: > node server/app.js
2016-04-18T21:27:36.994705+00:00 app[web.1]:
2016-04-18T21:27:37.784886+00:00 app[web.1]: Express server listening on 55648, in production mode
2016-04-18T21:28:34.891786+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-04-18T21:28:34.891786+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-04-18T21:28:35.750471+00:00 heroku[web.1]: Process exited with status 137
/server/config/environment/production.js
module.exports = {
database: 'DBNAME',
username: 'DBUSERNAME',
password: 'DBPASSWORD',
sql: {
host: 'DBHOST',
port: process.env.PORT || '5432',
dialect: 'postgres',
dialectOptions: {
ssl: true
}
}
};
/server/api/index.js
var sequelize = new Sequelize(config.database, config.username, config.password, config.sql);
Other than that, nothing was touched on server side.
My guess is that I am using Sequelize incorrectly, but I followed documentation (to adapt SSL for heroku).
Please, let me know if you want to see more configuration files.
Thank you for any input!
This:
var sequelize = new Sequelize(process.env.DATABASE_URL);
should be enough for connecting to Heroku's Postgres. You can check that DATABASE_URL in Heroku Dashboard -> YourApp -> Settings -> Config Variables. You can also take db credentials from that string, but you don't need to.
process.env.PORT is not the database port, but port on which you should start your server(so Heroku can do its internal routing things), like:
server.listen(process.env.PORT || 5432)
So you config file should look something like:
module.exports = {
port: process.env.PORT || 5432,
database: {
uri: process.env.DATABASE_URL
}
};
And connecting to database with:
var sequelize = new Sequelize(config.database.uri);

Unable to SSH to Google Cloud

I installed the Google Cloud SDK
Thought Web UI I created a new instance. I am not knowledgeable of SSH. I followed steps as described here: https://cloud.google.com/compute/docs/instances#sshkeys
I have Window 7 OS
I checked firewall rules as suggested here: https://cloud.google.com/compute/docs/troubleshooting#ssherrors
I checked these through Web UI and found rule
"default-allow-ssh 0.0.0.0/0 tcp:22 Apply to all targets"
STEPS I FOLLOWED:
1) > gcloud auth login
(default browser opens up and I authorize the Google Cloud SDK)
Google SDK Shell outputs:
"Saved Application Credentails. You are now logged as [someuser#gmail]
Your current project is [some-project-999].
2) > gcloud compute ssh my-instance --zone us-central1-a
Google SDK Shell outputs:
WARNING: You do not have an SSH key for Google Compute Engine.
WARNING: [C:\Program Files\Google\Cloud SDK\google-cloud-sdk\bin\..\bin\sdk\ssh-keygen.EXE] will be executed to generate
a key.
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
The key fingerprint is:
ssh-rsa 2048 06:73:ac:e8:f2:31:c8:df:d4:b0:a2:3b:a2:53:6c:09
Your private key has been saved in C:\Users\First Last\.ssh\google_compute_engine.
Your public key has been saved in C:\Users\First Last\.ssh\google_compute_engine.pub.
Your putty key has been saved in C:\Users\First Last\.ssh\google_compute_engine.ppk.
Updated [https://www.googleapis.com/compute/v1/projects/arctic-depth-863].
Server refused our key
FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey)
Server refused our key
FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey)
Server refused our key
FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey)
FATAL ERROR: Network error: Software caused connection abort
FATAL ERROR: Network error: Connection timed out
ERROR: (gcloud.compute.ssh) Could not SSH to the instance. It is possible that your SSH key has not propagated to the i
nstance yet. Try running this command again. If you still cannot connect, verify that the firewall and instance are set
to accept ssh traffic.
On the browser's Web UI, I open the Broser's SSH and I navigate to .ssh folder
someuser_gmail_com#my-instance:~$ cd .ssh
someuser_gmail_com#my-instance:~$ cat authorized_keys
# Added by Google
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4OxYxWvIlp...F7As google-ssh {"userName":"someuser#gmail.com","expireOn":"2015-02-21T23:29:06+0000"}
# Added by Google
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzd...KRqcUZmvWr= google-ssh {"userName":"someuser#gmail.com","expireOn":"2015-02-21T23:28:55+0000"}
on Web UI, I navigate to Project's > Compute > Compute Engine > Metadata > SSH KEYS and I see three records
USERNAME KEY
someuser_gmail_com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4...", "edpireOn":"2015-02-21T23:29:06+0000"}
someuser_gmail_com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTIt...", "edpireOn":"2015-02-21T23:29:06+0000"}
First Last ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAi...ZkpSpRt6RQ== First Last#MYPC
In my local computer, I navigate to Users/First Last/.ssh/google_compute_engine.pub and I see
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAit...mGhUKZRgFZkpSpRt6RQ== First Last#MYPC
QUESTIONS:
Does white space in the user's folder path causes problems (i.e. "First Last")?
When the key is created by the Google Cloud SDK, it sets the comment to First Last#MYPC. Is this the correct setting? (I have been reading and trying this and that and I suspect it should be something like someuser#my-instance-public-IP)
When I
Google Cloud SDK > gcloud compute instances describe my-instance --zone us-central1-a --format yaml
canIpForward: false
creationTimestamp: '2015-02-21T14:53:37.276-08:00'
disks:
- autoDelete: true
boot: true
deviceName: my-instance
index: 0
interface: SCSI
kind: compute#attachedDisk
licenses:
- https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-1204-precise
mode: READ_WRITE
source: https://www.googleapis.com/compute/v1/projects/some-project-999/zones/us-central1-a/disks/my-instance
type: PERSISTENT
id: '111812933445597333'
kind: compute#instance
machineType: https://www.googleapis.com/compute/v1/projects/some-project-999/zones/us-central1-a/machineTypes/g1-small
metadata:
fingerprint: w3steEkuQUS=
kind: compute#metadata
name: my-instance
networkInterfaces:
- accessConfigs:
- kind: compute#accessConfig
name: External NAT
natIP: 112.134.99.170
type: ONE_TO_ONE_NAT
name: nic0
network: https://www.googleapis.com/compute/v1/projects/some-project-999/global/networks/default
networkIP: 10.356.252.66
scheduling:
automaticRestart: true
onHostMaintenance: MIGRATE
selfLink: https://www.googleapis.com/compute/v1/projects/some-project-999/zones/us-central1-a/instances/my-instance
serviceAccounts:
- email: 78111222333-compute#developer.gserviceaccount.com
scopes:
- https://www.googleapis.com/auth/devstorage.read_only
- https://www.googleapis.com/auth/logging.write
status: RUNNING
tags:
fingerprint: DLYFgkKTlB3=
items:
- http-server
zone: https://www.googleapis.com/compute/v1/projects/some-project-999/zones/us-central1-a
C:\Program Files\Google\Cloud SDK>
This is a known issue when using Cloud SDK from Windows.
Please download pageant.exe at [1] and use it to load your ppk key or use Putty (downloadable from the same link) to SSH to instance as documented at [2].
As a workaround you can even rename ssh.exe to ssh-bak.exe and ssh-term.exe to ssh.exe in C:\Program Files\Google\Cloud SDK\google-cloud-sdk\bin\sdk\
Link:
[1] - http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
[2] - https://cloud.google.com/compute/docs/console#sshkeys

Resources