调用Lambda函数时,它会创建SNS主题,向其添加订阅者,然后向其发布消息。发布消息后,它将删除主题。要创建的主题名称和订阅者将作为有效负载提供给lambda函数。
有时它会工作,有时会失败,Task timed out after x seconds
因为我增加了Lambda超时时间,但仍然是同样的问题。
我挖了一点,发现
sns.createTopic(params, function(err, data) {
if(err) {
console.log('Error Creating SNS Topic:',err);
} else {
console.log('SNS Topic Created Successfully:',data);
}
}
Run Code Online (Sandbox Code Playgroud)
永不返回,没有错误,没有数据,我看不到结果 console.log()
当它工作时,一切都很好,但是当它失败时,我看不到找到问题。
编辑:
因此,我做了更多的挖掘工作,我将SNS主题创建的超时时间默认为5分钟,现在为5秒。当失败发生时,我得到这个“
{ [TimeoutError: Connection timed out after 5000ms]
message: 'Connection timed out after 5000ms',
code: 'NetworkingError',
time: Thu Mar 30 2017 15:35:20 GMT+0000 (UTC),
region: 'us-east-1',
hostname: 'sns.us-east-1.amazonaws.com',
retryable: true }
Run Code Online (Sandbox Code Playgroud)