Skip to content

Intermittently getting Quit inactivity timeout with Node.js 4.2.0 #1223

@ratneshdeepak

Description

@ratneshdeepak
Error: Quit inactivity timeout 
 at Quit.sequence.on.on.on.on.on.self._connection._startTLS.err.code (/var/task/node_modules/mysql/lib/protocol/Protocol.js:154:17) 
 at Quit.emit (events.js:92:17) 
 at Quit._onTimeout (/var/task/node_modules/mysql/lib/protocol/sequences/Sequence.js:116:8) 
 at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)

@dougwilson I'm using node on aws lambda. The problem is not persistent it reoccurs after every few requests only.

Here is the test code

 var mysql      = require('mysql');
 var mycontext = null;
 var table = "tableName";

if(typeof context === 'undefined'){
 context = {};
 context.fail = function(err){};
 context.succeed = function(o){ console.log("Contect o/p is"); console.log(o);};
 mycontext = context;
}
var processRequest = function (macaddress){
 var connection = null;
     connection = mysql.createConnection({
       host  : '*******',
          user   : '******',
          password : '*****',
          database : '******'
    });
     connection.connect(function(err){
     if(!err) {
         console.log("Database is connected ... \n\n");
     } else {
         console.log("Error connecting database ... \n\n");
         handleError(err);
     }
     });

 var getConf = function(mac){
  connection.query('SELECT * from '+table+' where macaddress = ? ',[mac], function(err, rows, fields) {
   if (!err){
     console.log('The o/p is: ', rows);
     if(rows.length == 0){
        insertConfig(mac)
     }
     else{
        dispatchConfig(rows[0]);
     }
   }
   else{
     handleError(err);
   }
   });
 };

var insertConfig = function(mac){
 connection.query('INSERT into '+table+' set macaddress = ? ',[mac], function(err, rows, fields) {   
    if(!err){
       console.log('The o/p is: ', rows);
       getConf(mac);
    }
    else
    {
      handleError(err);
    }
 });
}

var dispatchConfig = function(cf){
   connection.end();
   var output = JSON.parse(cf.config);
   output.unshift(["name",cf.id,"i"]);
   mycontext.succeed(JSON.stringify(output));

}

var handleError = function(err){
   connection.end();
   mycontext.fail('Something went wrong '+err);
   console.log('Error while performing Query.');
}

getConf(macaddress);

}

exports.handler = function(event, context) {
   mycontext = context;
   processRequest(event.macaddress); 
};

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions