AWS Lambda和Redis客户端.为什么我不能叫回叫? [英] AWS Lambda and Redis client. Why can't I call callback?
本文介绍了AWS Lambda和Redis客户端.为什么我不能叫回叫?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写一个使用Redis的AWS Lambda函数.当我运行以下代码时:
I'm trying to write an AWS Lambda function which uses Redis. When I run the code below:
'use strict'
function handler (data, context, callback) {
const redis = require("redis")
const _ = require("lodash")
console.log('before client')
const client = redis.createClient({
url: 'redis://cache-url.euw1.cache.amazonaws.com:6379',
})
console.log('after client')
callback(null, {status: 'result'})
console.log('after callback')
}
exports.handler = handler
我有一个这样的答案:
{
"errorMessage": "2016-09-20T15:22:27.301Z 07d24e0b-7f46-11e6-85e9-e5f48906c0da Task timed out after 3.00 seconds"
}
和日志如下:
17:22:24
START RequestId: 07d24e0b-7f46-11e6-85e9-e5f48906c0da Version: $LATEST
17:22:26
2016-09-20T15:22:26.014Z 07d24e0b-7f46-11e6-85e9-e5f48906c0da before client
17:22:26
2016-09-20T15:22:26.134Z 07d24e0b-7f46-11e6-85e9-e5f48906c0da after client
17:22:26
2016-09-20T15:22:26.135Z 07d24e0b-7f46-11e6-85e9-e5f48906c0da after callback
17:22:27
END RequestId: 07d24e0b-7f46-11e6-85e9-e5f48906c0da
17:22:27
REPORT RequestId: 07d24e0b-7f46-11e6-85e9-e5f48906c0da Duration: 3001.81 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 24 MB
17:22:27
2016-09-20T15:22:27.301Z 07d24e0b-7f46-11e6-85e9-e5f48906c0da Task timed out after 3.00 seconds
,恕我直言,这意味着调用了回调,但是什么也没发生.
which, IMHO, means that callback was called but nothing happened.
删除客户端的初始化后,我会看到正确的响应.
When I remove client's initialization I see proper response.
有什么想法吗?
推荐答案
查看全文