部署AWS Lambda部署程序包时出错 [英] Error when deploying AWS lambda deployment package

查看:163
本文介绍了部署AWS Lambda部署程序包时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试部署AWS lambda函数,并且已经用express编写了代码:

I am trying to deploy AWS lambda function and I have written code in express:

代码:

 var express = require('express');
    var bodyParser = require('body-parser');
    var lampress = require('lampress');
    var request = require('request');
    var port = process.env.PORT || 5000;
    var app = express();

    app.set('port', (port));

    // Process application/x-www-form-urlencoded
    app.use(bodyParser.urlencoded({extended: false}));

    // Process application/json
    app.use(bodyParser.json());

    // Index route
    app.get('/', function (req, res) {
        res.send('Hello! I am a Chatbot designed to help you learn  Type "begin" to start a chat! You can type "begin" at any time to return to the first menu');
    });

    // for Facebook verification
    app.get('/webhook/', function (req, res) {
        if (req.query['hub.verify_token'] === 'xyz') {
            res.send(req.query['hub.challenge']);
        }
        res.send('Error, wrong token');
    });

    // Spin up the server
     var server = app.listen(app.get('port'), function() {
       console.log('running on port', app.get('port'));
     });

    //figure out if your greeting text is working
    //need persistent menu?
    app.post('/webhook/', function (req, res) {
        getStarted();
        greetingText();
        messaging_events = req.body.entry[0].messaging;
        for (i = 0; i < messaging_events.length; i++) {

            event = req.body.entry[0].messaging[i];
            sender = event.sender.id;
            if (event.message && event.message.text) {
            //code
            }
            if (event.postback) {
            //code
            }
            console.log('********2');
        }
        res.sendStatus(200)
    });

    exports.handler = lampress(port, server);

错误:

     START RequestId: Version: $LATEST
2017-02-02T16:58:58.055Z    undefined   running on port 5000
2017-02-02T16:58:58.112Z        Error: SecurityError: Request method not allowed
    at openOnSocket (/var/task/node_modules/xmlhttprequest-socket/lib/XMLHttpRequest.js:191:13)
    at eventHandler.sendRequest (/var/task/node_modules/lampress/index.js:64:11)
    at eventHandler.handle (/var/task/node_modules/lampress/index.js:23:10)
    at /var/task/node_modules/lampress/index.js:87:13
END RequestId: e307361f-e968-11e6-b52d-7d8324fb6452
REPORT RequestId:   Duration: 99.26 ms  Billed Duration: 100 ms     Memory Size: 128 MB Max Memory Used: 33 MB  
RequestId:  Process exited before completing request

我有适当的node_modules.我的端口号出了问题吗?为什么方法不可访问

I have proper node_modules in place. Am I going somewhere wrong with port number and why methods are not accessible

访问API时,我得到:

When access the API I get:

{"errorMessage":"RequestId: xyz Process exited before completing request"}

压缩的zip结构 -> index.js -> node_modules文件夹.

compressed zip structure --> index.js --> node_modules folder.

package.json: "lampress":"^ 1.1.1"

package.json: "lampress": "^1.1.1"

推荐答案

报告(持续时间:99.26毫秒,计费持续时间:100毫秒).

REPORT (Duration: 99.26 ms Billed Duration: 100 ms ).

尝试在高级设置->(超时)中为代码设置更多时间.

Try to set more time for duration your code in advanced settings ->(Timeout).

这篇关于部署AWS Lambda部署程序包时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆