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" }
}
}

已提問 4 年前檢視次數 1033 次
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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南