Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(ASK) How we debug local websocket with AWS api gateway

I need to test my functions locally using AWS Web Socket API Gateway. Is there any possible way to mimic or duplicate the behaviour of AWS Web Socket in my local machine ? So I don't need to deploy every little changes to my Lambda function

Thanks

like image 920
Endy Santoso Avatar asked Apr 09 '19 14:04

Endy Santoso


People also ask

Does AWS API gateway support Websockets?

In API Gateway you can create a WebSocket API as a stateful frontend for an AWS service (such as Lambda or DynamoDB) or for an HTTP endpoint. The WebSocket API invokes your backend based on the content of the messages it receives from client apps.

How do I connect to AWS Websockets?

In order to create the WebSocket API, we need first go to Amazon API Gateway service using the console. In there choose to create new API. Click on WebSocket to create a WebSocket API, give an API name and our Route Selection Expression. In our case add $request.

How do I create a WebSocket API gateway?

To create a WebSocket API using the API Gateway consoleSign in to the API Gateway console and choose Create API. Under WebSocket API, choose Build. Under Settings, in the API name field, enter the name of your API, for example, PetStore . Enter a Route Selection Expression for your API, for example, $request.


2 Answers

Unfortunately we're still waiting on local sam support for v2 of API Gateway.

https://github.com/awslabs/aws-sam-cli/issues/896

like image 51
colsen Avatar answered Sep 28 '22 02:09

colsen


Recently I was able to find here that there is a workaround available called aws-lambda-ws-server which wraps the routes with a websocket server when ran locally and also works deployed as a AWS Lambda.

Hopefully this will help others in the future!

like image 30
fagiani Avatar answered Sep 28 '22 02:09

fagiani