我在 AWS Lambda NodeJS(使用无服务器框架)上实现简单查询时遇到了困难。在本地运行它可以工作,但是当我将它上传到 AWS 然后尝试使用 API Gateway 端点运行它时,我收到了这个错误:
{
"code": "PROTOCOL_INCORRECT_PACKET_SEQUENCE",
"fatal": true
}
我在 Google、StackOverflow 或 GitHub 上找不到有关此错误的任何信息,而且我无法弄清楚我做错了什么。
这就是我正在尝试的。
var mysql = require('mysql');
var connection = mysql.createConnection({
host : '',
user : '',
password : '',
database : ''
});
function getLists (client_id,api_key,callback){
connection.query("SELECT * FROM list WHERE client_id = ?",
[client_id],function(error, results){
connection.end();
callback(error,results);
}
)};
module.exports.run = function(event, context, cb) {
getLists(event.x_mail_list_client_id,'',function(error,results){
if(error){
return cb(null,error);
}
return cb(null,results);
});
};