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 Antwort
0
Akzeptierte Antwort

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
beantwortet vor 4 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen