I have a project with Node.js and MySQL. This project run well on local MAC osx. But have an error occurred when deploying on the centOS server. The project have 2 part, 1 is auto run with cron, that auto get data from one web, and update this data into MySQL. This part works fine on both local and online server. But another part is not, that part is display UI on browser, but when accessing it, an error is displayed.
Error: Cannot enqueue Query after fatal error.
at Protocol._validateEnqueue (/home/xx/node_modules/mysql/lib/p rotocol/Protocol.js:193:16)
at Protocol._enqueue (/home/xx/node_modules/mysql/lib/protocol/ Protocol.js:129:13)
at Connection.query (/home/xx/node_modules/mysql/lib/Connection .js:185:25)
at SessionStore.get (/home/xx/node_modules/express-mysql-sessio n/lib/index.js:92:18)
at session (/home/xx/node_modules/express-session/index.js:348: 11)
at Layer.handle [as handle_request] (/home/xx/node_modules/expr ess/lib/router/layer.js:82:5)
at trim_prefix (/home/xx/node_modules/express/lib/router/index. js:270:13)
at /home/xx/node_modules/express/lib/router/index.js:237:9
at Function.proto.process_params (/home/xx/node_modules/express /lib/router/index.js:312:12)
at /home/xx/node_modules/express/lib/router/index.js:228:12
(this error displayed on both console log and the browser, the project still running after that, so i guess this came from MySQL).
This is the sql connect file: simple is
var config = require('./config');
var mysql = require('mysql'),
host = config.hostName,
user = config.databaseUser,
password = config.databasePassword,
database = config.databaseName;
module.exports = mysql.createPool({
connectionLimit : 10,
host: host,
user: user,
password: password,
database: database
});
and this is how i call it:
imgExport.selectLast = function(callback){
conn.getConnection(function(err,conn) {
querySelectLast15Secon = "SELECT * FROM image WHERE year(moderate_time) = year(curdate()) AND month(moderate_time) = month(curdate()) AND (time(moderate_time) >= (curtime() - 15));";
conn.query(querySelectLast15Secon, function (err, rows, fields) {
if (err) throw err;
callback(rows);
conn.release();
})
});
};
i used console.dir(conn.threadId) before a code to debug, and it printed like that, so what is that mean? (each number in lines)
6177 6180 6181 6184 6183 6185 6176 6178 6179 6177 6183 6184 6185 6182 6180 6177 6176 6181 6183
npm install
on each system, or at least annpm rebuild
? There are native components to many database connectors. – Sodomitemysql
module is pure javascript, no compiling involved. – Mimeticnode_modules
and all, somewhere else.) – Sodomite