나는 redis (amazon elasticcache에서)를 사용하는 AWS Lambda 함수를 작성하려고합니다. 문제 - 내가 redis에 연결할 수 없습니다. 나는 확실히 내가 추가 행이 말이 안 뭔가 레디 스 URL을 변경할 때AWS Lambda and Redis
15:33:41
START RequestId: d8024ec2-7f36-11e6-996c-1bfcb60572c6 Version: $LATEST
15:33:42
2016-09-20T13:33:42.632Z d8024ec2-7f36-11e6-996c-1bfcb60572c6 before client initialization
15:33:42
2016-09-20T13:33:42.813Z d8024ec2-7f36-11e6-996c-1bfcb60572c6 after client initialization
15:33:44
END RequestId: d8024ec2-7f36-11e6-996c-1bfcb60572c6
15:33:44
REPORT RequestId: d8024ec2-7f36-11e6-996c-1bfcb60572c6 Duration: 3002.67 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 19 MB
15:33:44
2016-09-20T13:33:44.620Z d8024ec2-7f36-11e6-996c-1bfcb60572c6 Task timed out after 3.00 seconds
: 나는 로그에서이 같은 내용이 결과로이
'use strict'
function handler (data, context, cb) {
const redis = require("redis")
console.log('before client initialization')
const client = redis.createClient({
url: 'redis://propper-url-cache.some.0001.euw1.cache.amazonaws.com:6379',
retry_strategy: function(options) {
console.log(options)
if (options.total_retry_time > 1000) {
throw new Error('can`t connect to redis')
}
}
})
console.log('after client initialization')
client.on("error", function (err) {
console.log('in error')
cb({error: err})
});
client.get("counter", function (err, counter) {
console.log('counter', counter)
if(_.isNull(counter)) {
counter = 0
}
client.set('counter', counter + 1, function(err) {
console.log(err)
cb(null, {counter: counter})
})
});
}
exports.handler = handler
과 같은 코드를 사용
2016-09-20T13:29:42.953Z 48fcb071-7f36-11e6-bc52-c5ac58c12843 { attempt: 1, error: { [Error: Redis connection to some-url.euw1.cache.amazonaws.com:6379 failed - getaddrinfo ENOTFOUND some-url.euw1.cache.amazonaws.com some-url.euw1.cache.amazonaws.com:6379] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo', hostna
아이디어가 있으십니까?
람다 함수에 대해 VPC 액세스를 활성화 했습니까? –
그래, 문제는 VPC 액세스에있었습니다. 감사. 내가 왜 다른 행동을하는 이유가 있니? – kharandziuk
존재하지만 무언가에 액세스하려하지만 (부적절한 VPC 구성으로 인해) 네트워크 액세스 권한이 없으면 시간 초과가 발생합니다. 존재하지 않는 것을 액세스하려고하면 "찾을 수 없음"오류가 발생합니다. –