I wrote some basic js to just list FTP files, but I get:
"The process is completed before the request is completed"
Is it because Lambda cannot interact with FTP?
I am using jsftp btw.
Here is my setup:
- I use Serverless to create a project
- For my lambda, I used nodejs and I use JSFTP to work with ftp files.
My code is:
// Require Serverless ENV vars var ServerlessHelpers = require('serverless-helpers-js').loadEnv(); // Require Logic var lib = require('../lib'); // Lambda Handler module.exports.handler = function (event, context) { lib.respond(event, function (error, response) { return context.done(error, response); }); };
My ftp lambda code:
var JSFtp = require("jsftp"); module.exports.respond = function (event, cb) { var ftp = new JSFtp({ host: "host", user: "user", password: "password" }); ftp.auth(ftp.user, ftp.password, function(err, res) { if (err) console.log(err); else console.log(res); ftp.ls(".", function (err, res) { var results = []; res.forEach(function (file) { results.push(file.name); }); ftp.raw.quit(); return cb(null, results.length); }) }); };
I have added some console.log () throughout, and it seems like he was suffocating as soon as he tried to execute ftp.auth.
The output that I see in cloud mode:
START RequestId: __ID__ Version: $LATEST END RequestId: __ID__ REPORT RequestId: __ID__ Duration: 526.46 ms Billed Duration: 600 ms Memory Size: 1024 MB Max Memory Used: 33 MB Process exited before completing request
So it looks like he just choked somewhere ...
source share