javascript - How to solve error: Error: connect ETIMEDOUT at PoolConnection.Connection._handleConnectTimeout? - Stack Overflow

I am using Google Cloud App Engine with Nodejs And MYSQL. I am ensouting the error bellow, please help.

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
Add a ment  | 

1 Answer 1

Reset to default 2
  1. Please make sure that your Cloud SQL API is activated.
  2. 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信