AWS Lambda : errorMessage Process exited before completing request











up vote
0
down vote

favorite












Hi I'm newbie in android!



I want to upload image file from android client to server(Server makes thumbnail, and return thumbnail's url).



However I stucked in this error message.



{"errorMessage":"RequestId: 8e2a21b8-e62e-11e8-8585-d9b6fdfec9b9 Process exited before completing request"}!


I tried to find this error code in stackoverflow, but i cannot found answer for android.



Please help or give me link where I can solve this problem...



Here is server code.



const AWS = require('aws-sdk');
const multipart = require("parse-multipart");
const s3 = new AWS.S3();
const bluebird = require('bluebird');

exports.handler = function(event, context) {
let result = ;
const bodyBuffer = new Buffer(event['body-json'].toString(), 'base64');
const boundary = multipart.getBoundary(event.params.header['Content-Type']);
const parts = multipart.Parse(bodyBuffer, boundary);
const files = getFiles(parts);

return bluebird.map(files, file => {
console.log('UploadCall');
return upload(file)
.then(
data => {
result.push({
'bucket': data.Bucket,
'key': data.key,
'fileUrl': file.uploadFile.fullPath })
console.log( `DATA => ${JSON.stringify(data, null, 2 )}`);
},
err => {
console.log(`S3 UPLOAD ERR => ${err}`);
}
)
})
.then(_=> {
return context.succeed(result);
});
}

let upload = function(file) {
console.log('PutObject Call')
return s3.upload(file.params).promise();
};

let getFiles = function(parts) {
let files = ;
parts.forEach(part => {
const buffer = part.data

const fileName = part.filename;
const fileFullName = fileName;

const originBucket = 'dna-edge/images';
const filefullPath = `https://s3.ap-northeast-2.amazonaws.com/${originBucket}/${fileFullName}`;

const params = {
Bucket: originBucket,
Key: fileFullName,
Body: buffer
};

const uploadFile = {
size: buffer.toString('ascii').length,
type: part.type,
name: fileName,
fullPath: filefullPath
};
files.push({ params, uploadFile })
});
return files;
};


And this is client code.(imgURL looks like /storage/emulated/0/DCIM/img/1493742568136.jpg)



public static String requestHttpPostLambda(String url, String imgURL){

/*
await axios.post(`${AWS_LAMBDA_API_URL}?type=${type}`, formData,
{ headers: { 'Content-Type': 'multipart/form-data' }})
.then((response) => {result = response});
*/
String result=null;
try {
HttpClient client = new DefaultHttpClient();
String postURL = url;
HttpPost post = new HttpPost(postURL);
post.setHeader("Content-Type", "multipart/form-data");

File file = new File(imgURL);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addPart("image", new FileBody(file));
post.setEntity(builder.build());

HttpResponse responsePOST = client.execute(post);
Log.e("HttpResponse", responsePOST.getStatusLine()+"");
HttpEntity resEntity = responsePOST.getEntity();
if (resEntity != null) {
result = EntityUtils.toString(resEntity);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}









share|improve this question






















  • Possible duplicate of AWS Lambda "Process exited before completing request"
    – Pyae Phyoe Shein
    Nov 12 at 4:40










  • I think it's error in your codes. "Process exited before completing request" means that the Javascript function exited before calling return context.succeed(result);
    – Pyae Phyoe Shein
    Nov 12 at 4:43










  • @ppshein Do you mean the server code have some error, right? I thought android code had error... Because server runs no problem in React web client.
    – JooK
    Nov 12 at 4:53












  • regarding error message, that message Process exited before completing request typically coming from server side.
    – Pyae Phyoe Shein
    Nov 12 at 5:01















up vote
0
down vote

favorite












Hi I'm newbie in android!



I want to upload image file from android client to server(Server makes thumbnail, and return thumbnail's url).



However I stucked in this error message.



{"errorMessage":"RequestId: 8e2a21b8-e62e-11e8-8585-d9b6fdfec9b9 Process exited before completing request"}!


I tried to find this error code in stackoverflow, but i cannot found answer for android.



Please help or give me link where I can solve this problem...



Here is server code.



const AWS = require('aws-sdk');
const multipart = require("parse-multipart");
const s3 = new AWS.S3();
const bluebird = require('bluebird');

exports.handler = function(event, context) {
let result = ;
const bodyBuffer = new Buffer(event['body-json'].toString(), 'base64');
const boundary = multipart.getBoundary(event.params.header['Content-Type']);
const parts = multipart.Parse(bodyBuffer, boundary);
const files = getFiles(parts);

return bluebird.map(files, file => {
console.log('UploadCall');
return upload(file)
.then(
data => {
result.push({
'bucket': data.Bucket,
'key': data.key,
'fileUrl': file.uploadFile.fullPath })
console.log( `DATA => ${JSON.stringify(data, null, 2 )}`);
},
err => {
console.log(`S3 UPLOAD ERR => ${err}`);
}
)
})
.then(_=> {
return context.succeed(result);
});
}

let upload = function(file) {
console.log('PutObject Call')
return s3.upload(file.params).promise();
};

let getFiles = function(parts) {
let files = ;
parts.forEach(part => {
const buffer = part.data

const fileName = part.filename;
const fileFullName = fileName;

const originBucket = 'dna-edge/images';
const filefullPath = `https://s3.ap-northeast-2.amazonaws.com/${originBucket}/${fileFullName}`;

const params = {
Bucket: originBucket,
Key: fileFullName,
Body: buffer
};

const uploadFile = {
size: buffer.toString('ascii').length,
type: part.type,
name: fileName,
fullPath: filefullPath
};
files.push({ params, uploadFile })
});
return files;
};


And this is client code.(imgURL looks like /storage/emulated/0/DCIM/img/1493742568136.jpg)



public static String requestHttpPostLambda(String url, String imgURL){

/*
await axios.post(`${AWS_LAMBDA_API_URL}?type=${type}`, formData,
{ headers: { 'Content-Type': 'multipart/form-data' }})
.then((response) => {result = response});
*/
String result=null;
try {
HttpClient client = new DefaultHttpClient();
String postURL = url;
HttpPost post = new HttpPost(postURL);
post.setHeader("Content-Type", "multipart/form-data");

File file = new File(imgURL);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addPart("image", new FileBody(file));
post.setEntity(builder.build());

HttpResponse responsePOST = client.execute(post);
Log.e("HttpResponse", responsePOST.getStatusLine()+"");
HttpEntity resEntity = responsePOST.getEntity();
if (resEntity != null) {
result = EntityUtils.toString(resEntity);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}









share|improve this question






















  • Possible duplicate of AWS Lambda "Process exited before completing request"
    – Pyae Phyoe Shein
    Nov 12 at 4:40










  • I think it's error in your codes. "Process exited before completing request" means that the Javascript function exited before calling return context.succeed(result);
    – Pyae Phyoe Shein
    Nov 12 at 4:43










  • @ppshein Do you mean the server code have some error, right? I thought android code had error... Because server runs no problem in React web client.
    – JooK
    Nov 12 at 4:53












  • regarding error message, that message Process exited before completing request typically coming from server side.
    – Pyae Phyoe Shein
    Nov 12 at 5:01













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Hi I'm newbie in android!



I want to upload image file from android client to server(Server makes thumbnail, and return thumbnail's url).



However I stucked in this error message.



{"errorMessage":"RequestId: 8e2a21b8-e62e-11e8-8585-d9b6fdfec9b9 Process exited before completing request"}!


I tried to find this error code in stackoverflow, but i cannot found answer for android.



Please help or give me link where I can solve this problem...



Here is server code.



const AWS = require('aws-sdk');
const multipart = require("parse-multipart");
const s3 = new AWS.S3();
const bluebird = require('bluebird');

exports.handler = function(event, context) {
let result = ;
const bodyBuffer = new Buffer(event['body-json'].toString(), 'base64');
const boundary = multipart.getBoundary(event.params.header['Content-Type']);
const parts = multipart.Parse(bodyBuffer, boundary);
const files = getFiles(parts);

return bluebird.map(files, file => {
console.log('UploadCall');
return upload(file)
.then(
data => {
result.push({
'bucket': data.Bucket,
'key': data.key,
'fileUrl': file.uploadFile.fullPath })
console.log( `DATA => ${JSON.stringify(data, null, 2 )}`);
},
err => {
console.log(`S3 UPLOAD ERR => ${err}`);
}
)
})
.then(_=> {
return context.succeed(result);
});
}

let upload = function(file) {
console.log('PutObject Call')
return s3.upload(file.params).promise();
};

let getFiles = function(parts) {
let files = ;
parts.forEach(part => {
const buffer = part.data

const fileName = part.filename;
const fileFullName = fileName;

const originBucket = 'dna-edge/images';
const filefullPath = `https://s3.ap-northeast-2.amazonaws.com/${originBucket}/${fileFullName}`;

const params = {
Bucket: originBucket,
Key: fileFullName,
Body: buffer
};

const uploadFile = {
size: buffer.toString('ascii').length,
type: part.type,
name: fileName,
fullPath: filefullPath
};
files.push({ params, uploadFile })
});
return files;
};


And this is client code.(imgURL looks like /storage/emulated/0/DCIM/img/1493742568136.jpg)



public static String requestHttpPostLambda(String url, String imgURL){

/*
await axios.post(`${AWS_LAMBDA_API_URL}?type=${type}`, formData,
{ headers: { 'Content-Type': 'multipart/form-data' }})
.then((response) => {result = response});
*/
String result=null;
try {
HttpClient client = new DefaultHttpClient();
String postURL = url;
HttpPost post = new HttpPost(postURL);
post.setHeader("Content-Type", "multipart/form-data");

File file = new File(imgURL);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addPart("image", new FileBody(file));
post.setEntity(builder.build());

HttpResponse responsePOST = client.execute(post);
Log.e("HttpResponse", responsePOST.getStatusLine()+"");
HttpEntity resEntity = responsePOST.getEntity();
if (resEntity != null) {
result = EntityUtils.toString(resEntity);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}









share|improve this question













Hi I'm newbie in android!



I want to upload image file from android client to server(Server makes thumbnail, and return thumbnail's url).



However I stucked in this error message.



{"errorMessage":"RequestId: 8e2a21b8-e62e-11e8-8585-d9b6fdfec9b9 Process exited before completing request"}!


I tried to find this error code in stackoverflow, but i cannot found answer for android.



Please help or give me link where I can solve this problem...



Here is server code.



const AWS = require('aws-sdk');
const multipart = require("parse-multipart");
const s3 = new AWS.S3();
const bluebird = require('bluebird');

exports.handler = function(event, context) {
let result = ;
const bodyBuffer = new Buffer(event['body-json'].toString(), 'base64');
const boundary = multipart.getBoundary(event.params.header['Content-Type']);
const parts = multipart.Parse(bodyBuffer, boundary);
const files = getFiles(parts);

return bluebird.map(files, file => {
console.log('UploadCall');
return upload(file)
.then(
data => {
result.push({
'bucket': data.Bucket,
'key': data.key,
'fileUrl': file.uploadFile.fullPath })
console.log( `DATA => ${JSON.stringify(data, null, 2 )}`);
},
err => {
console.log(`S3 UPLOAD ERR => ${err}`);
}
)
})
.then(_=> {
return context.succeed(result);
});
}

let upload = function(file) {
console.log('PutObject Call')
return s3.upload(file.params).promise();
};

let getFiles = function(parts) {
let files = ;
parts.forEach(part => {
const buffer = part.data

const fileName = part.filename;
const fileFullName = fileName;

const originBucket = 'dna-edge/images';
const filefullPath = `https://s3.ap-northeast-2.amazonaws.com/${originBucket}/${fileFullName}`;

const params = {
Bucket: originBucket,
Key: fileFullName,
Body: buffer
};

const uploadFile = {
size: buffer.toString('ascii').length,
type: part.type,
name: fileName,
fullPath: filefullPath
};
files.push({ params, uploadFile })
});
return files;
};


And this is client code.(imgURL looks like /storage/emulated/0/DCIM/img/1493742568136.jpg)



public static String requestHttpPostLambda(String url, String imgURL){

/*
await axios.post(`${AWS_LAMBDA_API_URL}?type=${type}`, formData,
{ headers: { 'Content-Type': 'multipart/form-data' }})
.then((response) => {result = response});
*/
String result=null;
try {
HttpClient client = new DefaultHttpClient();
String postURL = url;
HttpPost post = new HttpPost(postURL);
post.setHeader("Content-Type", "multipart/form-data");

File file = new File(imgURL);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addPart("image", new FileBody(file));
post.setEntity(builder.build());

HttpResponse responsePOST = client.execute(post);
Log.e("HttpResponse", responsePOST.getStatusLine()+"");
HttpEntity resEntity = responsePOST.getEntity();
if (resEntity != null) {
result = EntityUtils.toString(resEntity);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}






android aws-lambda






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 at 4:09









JooK

14




14












  • Possible duplicate of AWS Lambda "Process exited before completing request"
    – Pyae Phyoe Shein
    Nov 12 at 4:40










  • I think it's error in your codes. "Process exited before completing request" means that the Javascript function exited before calling return context.succeed(result);
    – Pyae Phyoe Shein
    Nov 12 at 4:43










  • @ppshein Do you mean the server code have some error, right? I thought android code had error... Because server runs no problem in React web client.
    – JooK
    Nov 12 at 4:53












  • regarding error message, that message Process exited before completing request typically coming from server side.
    – Pyae Phyoe Shein
    Nov 12 at 5:01


















  • Possible duplicate of AWS Lambda "Process exited before completing request"
    – Pyae Phyoe Shein
    Nov 12 at 4:40










  • I think it's error in your codes. "Process exited before completing request" means that the Javascript function exited before calling return context.succeed(result);
    – Pyae Phyoe Shein
    Nov 12 at 4:43










  • @ppshein Do you mean the server code have some error, right? I thought android code had error... Because server runs no problem in React web client.
    – JooK
    Nov 12 at 4:53












  • regarding error message, that message Process exited before completing request typically coming from server side.
    – Pyae Phyoe Shein
    Nov 12 at 5:01
















Possible duplicate of AWS Lambda "Process exited before completing request"
– Pyae Phyoe Shein
Nov 12 at 4:40




Possible duplicate of AWS Lambda "Process exited before completing request"
– Pyae Phyoe Shein
Nov 12 at 4:40












I think it's error in your codes. "Process exited before completing request" means that the Javascript function exited before calling return context.succeed(result);
– Pyae Phyoe Shein
Nov 12 at 4:43




I think it's error in your codes. "Process exited before completing request" means that the Javascript function exited before calling return context.succeed(result);
– Pyae Phyoe Shein
Nov 12 at 4:43












@ppshein Do you mean the server code have some error, right? I thought android code had error... Because server runs no problem in React web client.
– JooK
Nov 12 at 4:53






@ppshein Do you mean the server code have some error, right? I thought android code had error... Because server runs no problem in React web client.
– JooK
Nov 12 at 4:53














regarding error message, that message Process exited before completing request typically coming from server side.
– Pyae Phyoe Shein
Nov 12 at 5:01




regarding error message, that message Process exited before completing request typically coming from server side.
– Pyae Phyoe Shein
Nov 12 at 5:01












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Welcome to stackoverflow.



So for some reason AWS aren't too good an updating the docs, don't use context.succeed, use the callback thats passed as a third param.



Also I'd move to Node 8.10 runtime because then rather than using promises/then pattern you can use async/await.



export default(event, context, callback) => {

try {

// do some stuff

callback(null, SOME_VALID_HTTP_RESPONSE)
} catch(e){

callback(e, null)
}
}


There's a few reason your Lambda could be failing, if the process exited before completing it's either crashing OR you're not returning a valid HTTP response(if your lambda is behind API gateway)



Two solutions - first place to look is in cloudwatch, find your lambda function name and check the latest log to look for error messages.



Second - check out my answer here so when your function succeeds you need to return a valid HTTP response to API Gateway so in essence if you use my code from there you can do:



callback(null, responder.success({someJson: someValue}))


Any questions let me know :-)



EDIT: I'm updating this question I'm just working on an example for a multiple file upload to S3!






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53255852%2faws-lambda-errormessage-process-exited-before-completing-request%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Welcome to stackoverflow.



    So for some reason AWS aren't too good an updating the docs, don't use context.succeed, use the callback thats passed as a third param.



    Also I'd move to Node 8.10 runtime because then rather than using promises/then pattern you can use async/await.



    export default(event, context, callback) => {

    try {

    // do some stuff

    callback(null, SOME_VALID_HTTP_RESPONSE)
    } catch(e){

    callback(e, null)
    }
    }


    There's a few reason your Lambda could be failing, if the process exited before completing it's either crashing OR you're not returning a valid HTTP response(if your lambda is behind API gateway)



    Two solutions - first place to look is in cloudwatch, find your lambda function name and check the latest log to look for error messages.



    Second - check out my answer here so when your function succeeds you need to return a valid HTTP response to API Gateway so in essence if you use my code from there you can do:



    callback(null, responder.success({someJson: someValue}))


    Any questions let me know :-)



    EDIT: I'm updating this question I'm just working on an example for a multiple file upload to S3!






    share|improve this answer



























      up vote
      0
      down vote













      Welcome to stackoverflow.



      So for some reason AWS aren't too good an updating the docs, don't use context.succeed, use the callback thats passed as a third param.



      Also I'd move to Node 8.10 runtime because then rather than using promises/then pattern you can use async/await.



      export default(event, context, callback) => {

      try {

      // do some stuff

      callback(null, SOME_VALID_HTTP_RESPONSE)
      } catch(e){

      callback(e, null)
      }
      }


      There's a few reason your Lambda could be failing, if the process exited before completing it's either crashing OR you're not returning a valid HTTP response(if your lambda is behind API gateway)



      Two solutions - first place to look is in cloudwatch, find your lambda function name and check the latest log to look for error messages.



      Second - check out my answer here so when your function succeeds you need to return a valid HTTP response to API Gateway so in essence if you use my code from there you can do:



      callback(null, responder.success({someJson: someValue}))


      Any questions let me know :-)



      EDIT: I'm updating this question I'm just working on an example for a multiple file upload to S3!






      share|improve this answer

























        up vote
        0
        down vote










        up vote
        0
        down vote









        Welcome to stackoverflow.



        So for some reason AWS aren't too good an updating the docs, don't use context.succeed, use the callback thats passed as a third param.



        Also I'd move to Node 8.10 runtime because then rather than using promises/then pattern you can use async/await.



        export default(event, context, callback) => {

        try {

        // do some stuff

        callback(null, SOME_VALID_HTTP_RESPONSE)
        } catch(e){

        callback(e, null)
        }
        }


        There's a few reason your Lambda could be failing, if the process exited before completing it's either crashing OR you're not returning a valid HTTP response(if your lambda is behind API gateway)



        Two solutions - first place to look is in cloudwatch, find your lambda function name and check the latest log to look for error messages.



        Second - check out my answer here so when your function succeeds you need to return a valid HTTP response to API Gateway so in essence if you use my code from there you can do:



        callback(null, responder.success({someJson: someValue}))


        Any questions let me know :-)



        EDIT: I'm updating this question I'm just working on an example for a multiple file upload to S3!






        share|improve this answer














        Welcome to stackoverflow.



        So for some reason AWS aren't too good an updating the docs, don't use context.succeed, use the callback thats passed as a third param.



        Also I'd move to Node 8.10 runtime because then rather than using promises/then pattern you can use async/await.



        export default(event, context, callback) => {

        try {

        // do some stuff

        callback(null, SOME_VALID_HTTP_RESPONSE)
        } catch(e){

        callback(e, null)
        }
        }


        There's a few reason your Lambda could be failing, if the process exited before completing it's either crashing OR you're not returning a valid HTTP response(if your lambda is behind API gateway)



        Two solutions - first place to look is in cloudwatch, find your lambda function name and check the latest log to look for error messages.



        Second - check out my answer here so when your function succeeds you need to return a valid HTTP response to API Gateway so in essence if you use my code from there you can do:



        callback(null, responder.success({someJson: someValue}))


        Any questions let me know :-)



        EDIT: I'm updating this question I'm just working on an example for a multiple file upload to S3!







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 12 at 14:28

























        answered Nov 12 at 14:16









        Mrk Fldig

        2,24341645




        2,24341645






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53255852%2faws-lambda-errormessage-process-exited-before-completing-request%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Guess what letter conforming each word

            Port of Spain

            Run scheduled task as local user group (not BUILTIN)