APIGateway Websocket enabe two-way communication not work on $connect route

0

I understand i can not use @connections api to push notify during @connect handler, cause at this time, the connection has not been established.

But why after enabled two-way communication, the $connect route response body still not push to client via websocket channel. It will be much simple since we can use this to implement somehting like server sent hello msg after client connected immediately.

Am i missing something here, or it just can not do this ? is there something i can use to implement server sent hello msg after client connected

unaki
preguntada hace 8 meses252 visualizaciones
1 Respuesta
1
Respuesta aceptada

Hi, Unfortunately $Connect route cannot send a response back to the client. The connection will get established successfully only when the $connect route complete its execution. Therefore, the response send by the downstream integration (like lambda function attched to $connect route) will not be send to the client. However as a workaround, You can trigger a lambda function "asynchronously" from the $connect route integration lambda function. In this new lambda functiom, you can check recursively whether the connection is established and then send a message to client using @connections api.

Client ------($Connect)------> Lambda Function--------(async Invocation)-----> Lambda function (send message using @connections api)

profile pictureAWS
INGENIERO DE SOPORTE
Bony_T
respondido hace 8 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas