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);
};
Hi! The error of Quit inactivity timeout means one of two things:
Quit packet to the MySQL server, nothing was never received from the MySQL server in response.connection.end(); is called and will throw that error if we don't hear anything back after that long. You can certainly try to increase the timeout, but it's likely that you'll just end up getting that error after a longer time. connection.end({ timeout: 60000 });Firewall issues can't explain intermittent behavior. Also I've setup mysql access open from all ip addresses.
Whenever this error occurs exception is thrown within few 100 milliseconds so 30 seconds timeout is also ruled out.
Can you suggest looking at anything else.
Interesting. I'll reopen as needs investigation, but I cannot think of anything to look into besides what was listed above. Perhaps there is a bug in this module or in Node.js core (which keeps track of the timeouts)?
I'm not able to reproduce, so without a way to reproduce the issue, there isn't much I can look into successfully. I can poke around at the code here, but it may not ever turn up anything of use. If you could debug your code and determine what is happening and issue up a PR, that's likely the best course of action :)
Had probably relevant issues like:
Error: Query inactivity timeout
at Query.<anonymous> (node_modules/mysql/lib/protocol/Protocol.js:154:17)
at Query._onTimeout (node_modules/mysql/lib/protocol/sequences/Sequence.js:116:8)
--------------------
at Pool.query (node_modules/mysql/lib/Pool.js:191:23)
....
when working with node v4.2.0 and moved to v4.2.1 to resolve it
I kept getting the same error too, but only with node v4.2.0, and upgrading to v4.2.1 also solved it for me.
Hi, more simple, this code was working for me on aws + lambda
/*--------------node mysql working example ------*/
var mysql = require('mysql');
var pool = mysql.createPool({
"host": "captainleads-cluster.cluster-XXCCX.eu-west-1.rds.amazonaws.com",
"user": "admin",
"password": "XXXXXX",
"database": "presta",
"connectionLimit": 10
});
console.log('Loading function');
exports.handler = function(event, context) {
pool.query('SELECT * FROM Go_users limit 1', function(err, rows, fields) {
if (err) {
throw err;
context.fail(rows);
}
console.log('The solution is: ', rows[0]);
context.succeed({user:rows[0],msg:'firstuser'});
});
};
Just FYI : Working fine on 4.2.2 and 4.2.3 .. Not working on 4.2.0
For those still coming across this issue, the bug is fixed. This is from a bug in Node.js 4.2.0 timers. You must upgrade your version of Node.js to actually receive the fix, or use a previous version of Node.js.
If AWS or other platforms only offer Node.js 4.2.0, then you may want to consider using a platform that does not force you to use versions of Node.js with known-fixed bugs.
I am re-opening this issue if someone wants to take a look into it, since apparently people are still running the issue and claim that upgrading to a version of Node.js that has the bug fix is not possible on AWS.
The only way this issue is going to move forward at this point is if someone wants to provide a pull request with the changes required for this module to work on Node.js 4.2.0. I will not be pursuing a fix, but if someone has a need to run this module on Node.js 4.2.0 and has the time to work on a fix and test it, please contribute.
Most helpful comment
Firewall issues can't explain intermittent behavior. Also I've setup mysql access open from all ip addresses.
Whenever this error occurs exception is thrown within few 100 milliseconds so 30 seconds timeout is also ruled out.
Can you suggest looking at anything else.