On an apigateway websocket is the status returned from the lambda handler?

0

When an error is returned from a lambda websocket handler I was expecting something to be seen on the client side. But nothing. I can send messages from the lambda function over the websocket so I know that path works. Is there some configuration or other magic I'm missing?

exports.handler = async (event, context) => {
try {
return { statusCode: 200, body: "OK" }
} catch (status) {
return { statusCode: 500, body: "XXXX" }
}
}

1 回答
0
已接受的回答

By default, WebSocket route is one-way, and it only sends a message to the client when API Gateway couldn't process the incoming message correctly.
In your case, API Gateway successfully executed the API, but your Lambda is returning 5xx. To send a result as a message to the client, you need to configure your route as "two-way" by configuring a route response.
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-route-response.html

AWS
已回答 4 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则

相关内容