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 Answer
0
Accepted Answer

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
answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions