我是AWS的新手,调试后,websocket出现问题,发现push lambda中出现身份验证错误。
push lambda如下:
module.exports.push = async (event, context) => {
try {
let client = new Aws.ApiGatewayManagementApi({
apiVersion: '2018-11-29',
endpoint: process.env.ENDPOINT
});
let arr=[];
//some loop
arr.push(client.postToConnection({ ConnectionId: "connection id here", Data: JSON.stringify("data") }, (err, data) => {
if (err) {
console.log("pushing failed: ", err); <<-- error here: UnknownError: Access denied. Token is missing -->>
}
else {
console.log("pushed to connection: ", data);
}
}).promise())
//loop ends
try {
await Promise.all(arr)
}
catch (err) {
return {
statusCode: 400
};
}
return {
statusCode: 200
};
}
catch (err) {
return {
statusCode: 400
};
}
};
不知道出了什么问题。有人可以帮我吗?