Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ratneshdeepak opened this issue Sep 21, 2015 · 9 comments
Closed
Assignees
Labels

Comments

@ratneshdeepak
Copy link

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); 
};
@dougwilson dougwilson self-assigned this Sep 24, 2015
@dougwilson
Copy link
Member

Hi! The error of Quit inactivity timeout means one of two things:

  1. Something on the network between AWS and your machine is broken. 99% of the time this is reported, it is determined that there is a bad rule on the machine's firewall. The error means that after sending the Quit packet to the MySQL server, nothing was never received from the MySQL server in response.
  2. Something is going really slow. We wait for 30 seconds after 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 });

@ratneshdeepak
Copy link
Author

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.

@dougwilson
Copy link
Member

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 :)

@dmtrs
Copy link

dmtrs commented Oct 15, 2015

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

@jczaplew
Copy link

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.

@bahout
Copy link

bahout commented Nov 26, 2015

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'});
    });

};

@shreyagarwal
Copy link

Just FYI : Working fine on 4.2.2 and 4.2.3 .. Not working on 4.2.0

@mysqljs mysqljs locked and limited conversation to collaborators Dec 18, 2015
@qarl qarl mentioned this issue Apr 27, 2016
@dougwilson
Copy link
Member

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.

@mysqljs mysqljs unlocked this conversation Apr 27, 2016
@dougwilson dougwilson changed the title Intermittently getting Quit inactivity timeout with 2.9.0 Intermittently getting Quit inactivity timeout with Node.js 4.2.0 Apr 27, 2016
@dougwilson
Copy link
Member

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.

@dougwilson dougwilson reopened this Apr 27, 2016
dougwilson added a commit that referenced this issue Jun 1, 2016
dougwilson added a commit that referenced this issue Jun 3, 2016
@mysqljs mysqljs deleted a comment from jmcazaux May 31, 2018
@mysqljs mysqljs deleted a comment from hauboldj May 31, 2018
@mysqljs mysqljs deleted a comment from jordie23 May 31, 2018
@mysqljs mysqljs deleted a comment from thiagomarini May 31, 2018
@mysqljs mysqljs deleted a comment from jonathanmv May 31, 2018
@mysqljs mysqljs deleted a comment from jboddiford May 31, 2018
@mysqljs mysqljs deleted a comment from jmcazaux May 31, 2018
@mysqljs mysqljs deleted a comment from hauboldj May 31, 2018
@mysqljs mysqljs deleted a comment from jmcazaux May 31, 2018
@mysqljs mysqljs deleted a comment from hauboldj May 31, 2018
@mysqljs mysqljs deleted a comment from jmcazaux May 31, 2018
@mysqljs mysqljs deleted a comment from hauboldj May 31, 2018
@mysqljs mysqljs deleted a comment from gvorster May 31, 2018
@mysqljs mysqljs locked as resolved and limited conversation to collaborators May 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

6 participants