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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠