【发布时间】:2018-08-12 19:37:20
【问题描述】:
我有以下两个 JS 文件。我的问题是当我调用调用 Archive.js 将日志归档到 DynamoDB 的 Calls.js 时,请求超时。 我已经尝试了很多东西,阅读了很多东西,在本地/AWS 环境中尝试过,但没有运气。我错过了什么?
Link1, Link2, Link3, Link4, Link5,
存档.js
module.exports.archive = archive;
...
function archive(input, callback){
AWS.config.update({
region: "eu-west-1",
endpoint: "http://localhost:8000"
});
var documentClient = new AWS.DynamoDB.DocumentClient({
httpOptions: {
agent: new https.Agent({
rejectUnauthorized: true,
secureProtocol: "TLSv1_method",
ciphers: "ALL"
})
}
});
...
var paramsPUT = {
TableName: "Logging",
Item: {
HashKey: dbID,
archiveEntry: archiveEntry
}
};
...
documentClient.put(paramsPUT, function(err, data) {
if (err) console.log(err);
if (data) console.log(data);
...
callback(data);
});
}
Calls.js
exports.handler(event, context, callback) => {
const archive = require("./..path..").archive;
...
context.callbackWaitsForEmptyEventLoop = false;
...
archive(input, callback);
...
}
【问题讨论】:
标签: node.js callback aws-lambda amazon-dynamodb