I have a very simple Websocket API hosted in AWS.
I am integrated this API with a Lambda function whose code is :
import json
def lambda_handler(event, context):
print(event)
return {
"isBase64Encoded": False,
"statusCode": 200,
"headers": {"Content-Type": "application/json"},
"body": json.dumps(event)
}
I have also added integration response for a two-way communication as stated in this documentation
Below is my test using wscat with the command : wscat -c myapiendpoint
As you can see, i am connected successfully and if i write an existing route from the request.body.action selection (sendMessage), there is no error but there is no output. If i write a wrong route (test that i have not created in the API Gateway console), i have got an error message.
I have also tried with more simple outputs from the function, none is working. I have finally wrote the above code as stated in this documentation.
I simply want to be able to send back a custom message to the client (actually data from my database) when a route is called.
This is actually what i want also for the $connect and $disconnect routes.
Am i doing something wrong ?
EDIT :
Here is my API Gateway setup for the route :
Here is a screenshot about the permission of the Lambda. By the way, these are the permissions for all of my Lambdas (under HTTP APIs) that all work fine :


