在查询MySQL数据库的第5个请求中,我当前收到一个sequentizeconnectionerror:Bad handshake error。在我对服务器执行的第5个请求中始终失败。
我在用nodejs。处理post请求的代码如下:
routes.post('/login', (req, res) => {
var email = req.body.email,
password = req.body.password;
models.User.findOne({ where: {email : email} }).then(function(user) {
if(user){
user.validPassword(password).then(result => {
if(result){
res.json({ "result": "Password correct"});
} else {
res.json({ "result": "Password incorrect"});
}
});
} else {
res.json({ "result": "User not found."});
}
});
});
user.validPassword如下:
User.prototype.validPassword = function(password){
var self = this;
return new Promise(function(resolve, reject){
cryptPassword(password, function(err, encrypted) {
resolve(self.password === encrypted);
});
});
}
我的续集配置如下:
var sequelize = new Sequelize(config.database, config.username, config.password, {
host: config.host,
dialect: config.dialect,
pool: {
max: 100,
min: 0,
idle: 10000,
handleDisconnects: true
}
});
我试过删除池,增加数量,检查MySQL上没有连接限制,确保不需要证书,然后重新安装MySQL服务器。
MySQL服务器运行在Ubuntu 14.04vps上,而不是Azure托管的,因为前面的一些问题是基于。
最佳答案
这是mysql2包的问题。我不得不删除它,改用mysql包。
希望这能帮助其他人,如果他们遇到同样的错误。