gpt4 book ai didi

node.js - NodeJS Sequelize - 启动应用程序时出错

转载 作者:行者123 更新时间:2023-12-03 22:41:35 31 4
gpt4 key购买 nike

当我尝试启动我的 Node 应用程序时出现以下错误:

Unhandled rejection SequelizeConnectionError: Connection lost: The server closed the connection.
at Handshake._callback (/Users/move/Vagrant/apps/appcampinas/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:95:20)
at Handshake.Sequence.end (/Users/move/Vagrant/apps/appcampinas/node_modules/mysql/lib/protocol/sequences/Sequence.js:86:24)
at /Users/move/Vagrant/apps/appcampinas/node_modules/mysql/lib/protocol/Protocol.js:399:18
at Array.forEach (native)
at /Users/move/Vagrant/apps/appcampinas/node_modules/mysql/lib/protocol/Protocol.js:398:13
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)

有没有人见过这个错误?

谢谢!

最佳答案

Sequelize 不支持自动重新连接,因此如果您的应用程序空闲运行,连接可能会断开。

处理此问题的首选方法是使用连接池。

{
"development": {
"username": "root",
"password": "root",
"database": "app_development",
"host": "127.0.0.1",
"dialect": "mysql",
"pool": {
"maxConnections": 100,
"maxIdleTime": 1000
},
"define": {
"underscored": true,
"freezeTableName": true,
"paranoid": true,
"charset": "utf8"
}
}
}

关于node.js - NodeJS Sequelize - 启动应用程序时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42417750/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com