1
我已經在nodejs中寫了一個簡單的lambda函數,用於從amazon rds中查詢數據(注意:我的lambda和rds是默認的vpc與所有開放端口,並嘗試在拉姆達增加超時)「errorMessage」:任務在3.00秒後超時aws lambda nodejs lambda函數試圖連接RDS
我的問題是,當我測試我的lambda函數,我得到日誌輸出與查詢的數據,但我也越來越
執行結果: 「errorMessage」失敗:「2017-07-05T15:05:27.425Z 596fdf39-6193-11e7-9176-f58796899f9b任務在3.00秒後超時」 }
var mysql = require('mysql');
exports.handler = (event, context) => {
var con = mysql.createConnection({
host: "testdb.cxyzu.ap-south-1.rds.amazonaws.com",
user: "root",
password: "mypassword",
database: "test",
port: "3306",
// debug: true
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
// var sql = "INSERT INTO users (id, name) VALUES (4, 'dfdd')";
var sql = "select * from test.users";
con.query(sql, function (err, result) {
if (err) throw err;
// console.log("1 record inserted");
console.log(result);
});
});
//callback("sucess");
}
START RequestId: 596fdf39-6193-11e7-9176-f58796899f9b Version: $LATEST
2017-07-05T15:05:24.680Z \t 596fdf39-6193-11e7-9176-f58796899f9b \t Connected!
2017-07-05T15:05:24.684Z \t 596fdf39-6193-11e7-9176-f58796899f9b \t [ RowDataPacket { id: 1, name: 'sai' },
RowDataPacket { id: 2, name: 'chandra' },
RowDataPacket { id: 3, name: 'AA' },
RowDataPacket { id: 4, name: 'dfdd' } ]
END RequestId: 596fdf39-6193-11e7-9176-f58796899f9b
REPORT RequestId: 596fdf39-6193-11e7-9176-f58796899f9b \t Duration: 3003.80 ms \t Billed Duration: 3000 ms \t Memory Size: 1536 MB \t Max Memory Used: 21 MB \t
2017-07-05T15:05:27.425Z 596fdf39-6193-11e7-9176-f58796899f9b Task timed out after 3.00 seconds
非常感謝您的回覆。我會努力的。 – chandra
真棒工作。感謝了很多。 – chandra
然後標記問題解決:) –