My question is as follows :
abc lambda triggering another lambda(named : khjj) Everything is going fine for me only the thing is that in the cloudwatch logs or even in locally if I run the abc lambda function to trigger the khjj lambda, I am getting socket hangup error after my requests.
My abc lambda reads one data from a dynamo db table and row by row triggers the khjj function, the code in abc lambda is :
var cronjob = module.exports = {
data : function(){
return new Promise(function (resolve, reject) {
arrayData = []
// here data.get is a function in the same file for getting the
// data from the dynamo db table
data.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);
})
}
Now the above lambda function triggering the "khjj" lambda, so there is awsServerlessExpress function I used in the "khjj" lambda function so it is getting request here in the code :
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();
})
})
The socket error is coming in the above lambda i.e. khjj, searched all over the net even stackoverflow and aws forums as well but not got any solution
Even considered this website : https://gregjs.com/javascript/2015/how-to-scrape-the-web-gently-with-node-js/
Please any help would be fine. Thanks.
via learner
No comments:
Post a Comment