1

Unhandled rejection Error: Handshake inactivity timeout. I run app and get the error during connection to db in case to get data. I removed node_modules folder. Changed version of node via nvm from 4.4.7 to 6.10.0. Installed node_modules again. Tried to enlarge timeout of connection options. Tried to use mysql2 without promisify all. Nothing helped. I read about confilcts of DNS addresses with router ( however the connection is working with node 4.4.7). I also understand that the same issue was in previous versions, but I did not find strong and understandable answer, only suggestions about routing, CPU, wrong config connections.

OS: Centos 7 
node //Now using node v6.10.0 (npm v3.10.10) via nvm
mysql module: 2.13.0
mysql db : //some DNS name (not local), port : 3306

CODE(lib/mysql/index.js)

var Promise = require("bluebird");
// The most popular mysql module
var mysql   = require('mysql');

// Note that the library's classes are not properties of the main export
// so we require and promisifyAll them manually
Promise.promisifyAll(require("mysql/lib/Connection").prototype);
Promise.promisifyAll(require("mysql/lib/Pool").prototype);

var config      = require(__base + '/config');
var connections = {};

Object.keys(config.mysql).forEach(function (name) {
    var options       = config.mysql[name];
    new Connection(name, options || null);
});

/**
 * @param name
 * @param options
 *       host    : options.host,
 *       port    : options.port,
 *       user    : options.user,
 *      password: options.password,
 *      database: options.database
 *
 * @constructor
 */
function Connection(name, options) {
    this.name                     = name;
    var connectionObj             = options;

    connectionObj.connectionLimit = 10;   
    this.pool                     = mysql.createPool(connectionObj);

    this.runQuery = function (query) {
        return this.pool.queryAsync(query);       
    };
    connections[name] = this;
}
function setConnection(name , options ){
    connections[name] = new Connection(name,options)
}
function getConnection( name, options ){
    if( !connections[name]){
        setConnection(name,options);
    }
    return connections[name];
}

exports.connections = connections;
exports.getConnection = getConnection;


Unhandled rejection Error: Handshake inactivity timeout
at Handshake.<anonymous>
    (/home/User/code/application/node_modules/mysql/lib/protocol/Protocol.js:160:17)
    at emitNone (events.js:86:13)
    at Handshake.emit (events.js:185:7)
    at Handshake._onTimeout (/home/User/code/application/node_modules/mysql/lib/protocol/sequences/Sequence.js:127:8)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)
    --------------------
    at Protocol._enqueue (/home/User/code/application/node_modules/mysql/lib/protocol/Protocol.js:141:48)
    at Protocol.handshake (/home/User/code/application/node_modules/mysql/lib/protocol/Protocol.js:52:41)
    at PoolConnection.connect (/home/User/code/application/node_modules/mysql/lib/Connection.js:130:18)
    at Pool.getConnection (/home/User/code/application/node_modules/mysql/lib/Pool.js:48:16)
    at Pool.query (/home/User/code/application/node_modules/mysql/lib/Pool.js:202:8)
    at Pool.tryCatcher (/home/User/code/application/node_modules/bluebird/js/release/util.js:16:23)
    at Pool.ret [as queryAsync] (eval at makeNodePromisifiedEval (/home/User/code/application/node_modules/bluebird/js/release/promisify.js:205:1), <anonymous>:14:23)
    at Connection.__dirname.Connection.options.runQuery (/home/User/code/application/lib/mysql/index.js:50:26)
    at TableName.runQuery (/home/User/code/application/models/mysql/abstract.js:51:34)
    at TableName.proto.getAll (/home/User/code/application/models/mysql/abstract.js:60:17)
    at new TableName (/home/User/code/application/models/mysql/table_name.js:11:33)
    at Object.<anonymous> (/home/User/code/application/models/mysql/table_name.js:58:18)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)

I tried to enlarge timeout like here: Error: Handshake inactivity timeout in Node.js MYSQL module.

I read about DNS settings here: Error: Handshake inactivity timeout in Node.js v6.9.1 and MYSQL . (With node 4.4.7 there is no issues).

Community
  • 1
  • 1
slby
  • 11
  • 4

1 Answers1

0

App run in IDE WebStorm v.11 in debugg mode and failed. I updated the IDE to newer version 2016.3. The issue gone away.

slby
  • 11
  • 4