DEV Community

Discussion on: How I can invoke locally my lambda using API Gateway Websocket $connect and $disconnect routes so I can debug them?

Collapse
 
rolfstreefkerk profile image
Rolf Streefkerk

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

Collapse
 
pcmagas profile image
Dimitrios Desyllas

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:

sam local invoke ^Lambda_name^ --event event.json

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.

Collapse
 
rolfstreefkerk profile image
Rolf Streefkerk

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.