连接丢失:服务器关闭了连接Nodejs Mysql

时间:2020-09-22 11:12:30

标签: mysql node.js server connection backend

我在节点应用程序中使用node-mysql库。但是每天Windows服务器上的mysql服务都会重新启动,因此我的节点应用程序会提示错误“服务器已关闭连接”。我已经使用nodemon软件包重新启动服务器,但是发生此错误时它无法重新启动。因此,我必须每天手动重新启动服务器。我在这里nodejs mysql Error: Connection lost The server closed the connection找到了解决方案。但是我已经导出了我的连接变量。但是它仍然显示旧的连接实例,并且不执行查询。谁能帮我 ?我不想使用池连接。这是我的代码。

if (context.auth) {

    if(isLimitExceeded){

       // limit is exceeded, reject

    } else {

      //limit not exceeded and the user is authenticated perform the search

    } 

} else {

    // user is not authenticated , perform rejection
}

0 个答案:

没有答案