使用连接池时连接超时

时间:2016-09-17 11:12:46

标签: mysql express

从连接池获取连接对象时出现以下错误。它有时会起作用,但有时我会收到错误并且Activity未定义。我不认为我应该得到连接超时错误,因为我正在使用连接池,并且在连接池中,您已经有一些连接而且您没有创建新连接。

有人可以告诉我如何处理此错误并再次连接。

connection

处的错误
getConnection

代码:

{ [Error: connect ETIMEDOUT]
  errorno: 'ETIMEDOUT',
  code: 'ETIMEDOUT',
  syscall: 'connect',
  fatal: true }

我在使用池化对象时遇到错误:

    var pool  = mysql.createPool({
    connectionLimit : 100, //important
     host     : '192.168.2.2',
     user     : 'testmysql',
     password : 'test123',
     database : 'tollsystem',
     debug    :  false
});

错误:

    app.get('/getClientList',function(req,res){
    var data={
        "error":1,
        "clients":""
    };
    pool.getConnection(function(err,connection){
    console.log(err);
    connection.query("select * from mstrclient",function(err,rows,fields){

        if(rows.length !=0){
            res.json(rows);
        }else{
            data["error"]=1;
            data["clients"]="no details found";
            res.json(data);
        }
        connection.release();
    })
  });
});

0 个答案:

没有答案