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

1 Answer
1
Accepted Answer

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
Bony_T
answered 7 months 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