2017-03-13 3 views
0

처리되지 않은 거부 오류 : 핸드 셰이크 비활성 시간 제한. app을 실행하고 데이터를 가져올 경우 db에 연결하는 동안 오류가 발생합니다. node_modules 폴더를 제거했습니다. nvm을 통해 4.4.7에서 6.10.0으로 노드의 버전이 변경되었습니다. node_modules를 다시 설치했습니다. 연결 옵션의 시간 초과를 시도했습니다. promisify하지 않고 mysql2를 사용하려고했습니다. 아무것도 도움이되지 않았습니다. 라우터로 DNS 주소 confilcts에 대해 읽었습니다 (그러나 연결은 노드 4.4.7에서 작동합니다). 또한 같은 문제가 이전 버전에서 발생했음을 이해하지만 강력하고 이해할 수있는 대답을 찾지 못했습니다. 라우팅, CPU, 잘못된 구성 연결에 대한 제안 만 있습니다.핸드 셰이크 비활성 시간 제한 : nodejs 6.10.0 mysql pool.queryAsync

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) 

은 여기처럼 시간 제한을 확대하려 : Error: Handshake inactivity timeout in Node.js MYSQL module.

여기에서 DNS 설정에 대해 읽었습니다 : Error: Handshake inactivity timeout in Node.js v6.9.1 and MYSQL. (노드 4.4.7에서는 문제가 없음).

답변

0

응용 프로그램이 IDE WebStorm v.11에서 디버그 모드로 실행되어 실패했습니다. IDE를 최신 버전 2016.3으로 업데이트했습니다. 문제가 사라졌습니다.