I am using Google Cloud App Engine with Nodejs And MYSQL. I am ensouting the error bellow, please help. I did some research but nothing is similar to be working, the connection.release() and connection.end() The error message shows as bellow:
{ Error: connect ETIMEDOUT at PoolConnection.Connection._handleConnectTimeout
(/app/node_modules/mysql/lib/Connection.js:411:13) at Object.onceWrapper
(events.js:286:20) at Socket.emit (events.js:198:13) at Socket._onTimeout (net.js:442:8)
at ontimeout (timers.js:436:11) at tryOnTimeout
(timers.js:300:5) at listOnTimeout (timers.js:263:5) at Timer.processTimers (timers.js:223:10)
The connection is created this way:
//create connection
var connection = mysql.createPool
({
host : 'host_here',
user : 'root',
connectionLimit : 1000,
password : 'the_password',
database : 'the_dbname',
port : 3306,
charset : 'utf8mb4'
});
global.db = connection;
The on my route I do the following which results to above-mentioned error:
db.getConnection(function(err, connection)
{
if (err)
{
console.log("Connection ERROR")
console.log(err);
}
else
{
connection.query('SELECT * FROM `my_table_name`', function (error, results, fields)
{
// When done with the connection, release it.
connection.release();
// Handle error after the release.
if (error)
{
console.log("ERROR")
console.log(error);
}
if (results)
{
console.log("Results")
console.log(results)
}
if(fields)
{
console.log("FIELDS")
console.log(fields)
}
});
}
});
I am using Google Cloud App Engine with Nodejs And MYSQL. I am ensouting the error bellow, please help. I did some research but nothing is similar to be working, the connection.release() and connection.end() The error message shows as bellow:
{ Error: connect ETIMEDOUT at PoolConnection.Connection._handleConnectTimeout
(/app/node_modules/mysql/lib/Connection.js:411:13) at Object.onceWrapper
(events.js:286:20) at Socket.emit (events.js:198:13) at Socket._onTimeout (net.js:442:8)
at ontimeout (timers.js:436:11) at tryOnTimeout
(timers.js:300:5) at listOnTimeout (timers.js:263:5) at Timer.processTimers (timers.js:223:10)
The connection is created this way:
//create connection
var connection = mysql.createPool
({
host : 'host_here',
user : 'root',
connectionLimit : 1000,
password : 'the_password',
database : 'the_dbname',
port : 3306,
charset : 'utf8mb4'
});
global.db = connection;
The on my route I do the following which results to above-mentioned error:
db.getConnection(function(err, connection)
{
if (err)
{
console.log("Connection ERROR")
console.log(err);
}
else
{
connection.query('SELECT * FROM `my_table_name`', function (error, results, fields)
{
// When done with the connection, release it.
connection.release();
// Handle error after the release.
if (error)
{
console.log("ERROR")
console.log(error);
}
if (results)
{
console.log("Results")
console.log(results)
}
if(fields)
{
console.log("FIELDS")
console.log(fields)
}
});
}
});
Share
Improve this question
asked Sep 19, 2019 at 10:25
Fezekile PlaatyiFezekile Plaatyi
511 gold badge1 silver badge7 bronze badges
2
- Hello, Are you attempting to connect to an external to GCP MySQL Instance or a Google CloudSQL instance? Standard or Flexible App Engine? – Stefan G. Commented Sep 19, 2019 at 11:08
- Yes I am trying to connect to it using the App just I just deployed in there, Flexible APp Engine it is – Fezekile Plaatyi Commented Sep 19, 2019 at 11:12
1 Answer
Reset to default 2- Please make sure that your Cloud SQL API is activated.
- Make sure that your Cloud SQL Instance is a Second Generation one.
Here you have a step-by-step Node.JS in App Engine Flex connection to a CloudSQL instance.
Let me know.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744713580a4589486.html
评论列表(0条)