简体   繁体   English

NodeJS运行在Mac上,在centOS上部署时出现错误

[英]NodeJS running on Mac, and have an error occurred when deploying on centOS

I have a project with Node.js and MySQL.我有一个使用 Node.js 和 MySQL 的项目。 This project run well on local MAC osx.该项目在本地 MAC osx 上运行良好。 But have an error occurred when deploying on the centOS server.但是在centOS服务器上部署时出现错误。 The project have 2 part, 1 is auto run with cron, that auto get data from one web, and update this data into MySQL.该项目有 2 部分,1 部分是使用 cron 自动运行的,即自动从一个网络获取数据,并将这些数据更新到 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.但是另一部分不是,那部分是在浏览器上显示UI,但是在访问它时会显示错误。

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). (此错误显示在控制台日志和浏览器上,此后项目仍在运行,所以我猜这来自 MySQL)。

This is the sql connect file: simple is这是sql连接文件: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?我在调试代码之前使用了console.dir(conn.threadId),它是这样打印的,那是什么意思? (each number in lines) (行中的每个数字)

6177 6180 6181 6184 6183 6185 6176 6178 6179 6177 6183 6184 6185 6182 6180 6177 6176 6181 6183 6177 6180 6181 6184 6183 6185 6176 6178 6179 6177 6183 6184 6185 6182 6180 6177 6176 6181 6183

Fixed!固定的! The problem is from express-sql-session!问题来自 express-sql-session! I removed it from the code and its works fine.我从代码中删除了它并且它工作正常。 So i think i need to report this problems for them in here:所以我想我需要在这里为他们报告这个问题:

https://github.com/chill117/express-mysql-session/issues https://github.com/chill117/express-mysql-session/issues

I think there is some issue with connection.end() in that module.我认为该模块中的 connection.end() 存在一些问题。 Dont know where but maybe should take a time to find it out.不知道在哪里,但也许应该花一些时间才能找到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 连接到MySQL时Mac上的Node.js错误 - nodejs on mac error when connecting to mysql 尝试启动MySQL守护程序时发生超时错误。 CentOS 5 - Timeout error occurred trying to start MySQL Daemon. CentOS 5 在centos tomcat上运行Spring Boot Application时出错 - Error on Running Spring Boot Application on centos tomcat Mysql 进行相关查询时发生常量字段错误 [Err] 1064 - 您的 SQL 语法有错误; - Mysql constant field error occurred when doing related query [Err] 1064 - You have an error in your SQL syntax; 即使发生错误,也会提交MySQL事务 - MySQL transaction is committed even when error occurred 在 Mac 上运行 mysql 时,ERROR COLLATION 'utf8_unicode_ci' 对 CHARACTER SET 'utf8mb4' 无效 - ERROR COLLATION 'utf8_unicode_ci' is not valid for CHARACTER SET 'utf8mb4' when running mysql on Mac 部署时使用Crystal Reports部署clickonce Windows应用程序时出错 - Error in deploying clickonce windows app with crystal reports when deploying 应用程序出错,无法提供您的页面 Deploying Node.Js REST to heroku - An error occurred in the application and your page could not be served Deploying Node.Js REST to heroku MySQL 5.7.21 已安装 Mac 但有首选项错误 - MySQL 5.7.21 Installed Mac but have Preferences Error 部署.NET应用程序时出现MySQL错误 - MySQL error when deploying .NET application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM