0
我的问题如下:Node.js的错误
ABC拉姆达触发另一个lambda(命名为:khjj) 一切都正常,我唯一的事情是,在CloudWatch的日志,甚至在局部如果我运行abc lambda函数来触发khjj lambda,那么我的请求之后会出现套接字挂起错误。
我的ABC拉姆达读取来自一个发电机分贝表和逐行一个数据触发khjj功能,在ABC拉姆达的代码是:
var sendData = module.exports = {
data : function(){
return new Promise(function (resolve, reject) {
arrayData = []
// here table.get is a function in the same file for getting the
// data from the dynamo db table
table.get("Table1").then(function(response){
_.forEach(response, function(data){
var obj = {};
obj.value1 = data.value1;
obj.value2 = data.value2;
obj.value3 = data.value3;
obj.value4 = data.value4;
obj.value5 = data.value5;
obj.value6 = data.value6;
obj.value7 = data.value7;
arrayData.push(obj)
})
Promise.all(arrayData).then(function(objs){
async.each(objs, function(data, callback){
request({
headers: {'Content-Type':'application/json'},
url : // here I used lambda khjj url here,
method: 'POST',
body: company,
json: true
}, function (err, res, body) {
if(!_.isNil(err)){
console.log(err);
console.log('error in triggering')
} else {
// tried this callback as well to stop that error of socket hangup
callback(null, 'success')
}
})
}, function(err){
console.log()
})
}, function(err){
console.log(err)
})
}, function(err){
console.log('error in getting data from table :', err)
})
resolve(true);
})
}
现在上述lambda函数触发“khjj”拉姆达所以我在“khjj”拉姆达函数中使用,因此在这里获得请求的代码awsServerlessExpress功能:
app.post('/called/by/abc/lambda', function(req,
resp){
check.message(request).then(function(response){
resp.write('success')
resp.end();
}, function(err){
console.log(err)
resp.end();
})
})
插座错误是在上面的拉姆达即khjj到来,找遍了网甚至计算器和aws论坛,但没有得到Ÿ解决方案
即使考虑过这个网站:https://gregjs.com/javascript/2015/how-to-scrape-the-web-gently-with-node-js/
请任何帮助就可以了。谢谢。
CloudWatch的错误:
2017-05-25T13:30:15.043Z 009c3110-414e-11e7-99b5-b3bd2686fba3
{ Error: socket hang up
at createHangUpError (_http_client.js:253:15)
at Socket.socketOnEnd (_http_client.js:345:23)
at emitNone (events.js:91:20)
at Socket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback
(internal/process/next_tick.js:128:9) code: 'ECONNRESET' }
您能否将堆栈跟踪记录到cloudwatch并在此处提供? –
是的,我更新了日志错误。 – learner