Cannot enqueue Handshake after invoking quit

前端 未结 10 2296
小鲜肉
小鲜肉 2020-11-28 02:59

I have implemented the following code:

module.exports = {
    getDataFromUserGps: function(callback)
    {
        connection.connect();
        connection.qu         


        
10条回答
  •  时光取名叫无心
    2020-11-28 03:45

    SOLUTION: to prevent this error(for AWS LAMBDA):

    In order to exit of "Nodejs event Loop" you must end the connection, and then reconnect. Add the next code to invoke the callback:

    connection.end( function(err) {
            if (err) {console.log("Error ending the connection:",err);}
    
           //  reconnect in order to prevent the"Cannot enqueue Handshake after invoking quit"
    
             connection = mysql.createConnection({
                    host     : 'rds.host',
                    port     :  3306,
                    user     : 'user',
                   password : 'password',
                   database : 'target database'
    
                   });
            callback(null, {
                statusCode: 200,
                body: response,
    
            });
        });
    

提交回复
热议问题