I need your help with this:
I try to use lambdas with my AWS websocket api gateway.
I have made the following template.yaml
:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: "On connect and on disconnect handler"
Parameters
DB_HOSTName:
Type: String
Default: '0.0.0.0:3306'
Description: Database host
DB_USERName:
Type: String
default: myuser
Description: Database User
DB_PASSWORDName:
Type: String
default:
…
I try to run locallym an aws lambda that is triggered via API Gateway's websocket. Based upon this: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-start-api.html I tried to run it locally without a success.
Top comments (3)
There's no local variant of the API Gateway v2 except for HTTP API's, there's no websocket support (yet). You'll need to emulate this yourself with a node Express server I'm afraid
At least how I can emulate the event that the websocket will trigger. I mean even though I cannot run locally websockets I can trigger lambda execution via:
So what should I place on
event.json
in order to emulate a$connect
and$disconnect
event that Api Gateway will trigger? Even if I use nodejs and websockets I will need to emulate these events but I have not idea how.either capture the event in your logs when you've deployed the API Gateway Websocket with Lambda integration. OR search on google what the event structure is for a WebSocket Lambda integration.