I am implementing an application with API Gateway, Websocket and Lambda/Python. However, I encountered an issue and would appreciate if anybody could provide a solution or workaround.
Below is the composition of my application:
- web application: running in ec2, providing photo uploading function.
- some facial recognition cameras: connected to API Gateway, acting as Websocket client.
- Lambda #1: implemented as $connect route of API Gateway, saving the Websocket connection id in dynamo
- Lambda #2: implemented as standalone Lambda, will be triggered when photo is uploaded on web application, get connection id from dynamo, call some Websocket api of the camera to upload photo to the camera.
The problem is that the result from the Websocket api of the camera is not received in Lambda #2.
The response has ResponseMetadata, with HTTPStatusCode 200 and content-length is 0.
I checked the camera and can tell the Websocket api is actually called, and using wscat as Websocket Server, the result from the camera can be received.
I guess maybe the result is received at API Gateway because the Websocket connection is between the camera and API Gateway, but not the camera and Lambda #2, so I should find some way to get the result out of the API Gateway. I checked the API Gateway document, Set up route responses for a WebSocket API in API Gateway seems similar but it is setting response to client side(camera), what I need is response to server side.
Another possibility is maybe the ApiGatewayManagementApi post_to_connection
just not return the response. Document of Boto says RETURNS: None
.
Another method get_connection
can get some response because the document says so.