Amazon API Gateway WebSocket acknowledgement for $connect route.

Amazon API Gateway WebSocket API → AWS Lambda → AWS Lambda

This pattern demonstrates acknowledging WebSocket connections with API Gateway and AWS Lambda

The Serverless Application Model (SAM) template deploys an Amazon WebSocket API Gateway and two AWS Lambda functions. When a client connects, the API Gateway creates a $connect route with Lambda proxy integration. The first Lambda function processes the initial connection, capturing both the Connection ID and API Gateway stage URL, then asynchronously invokes the second Lambda function. This second function validates the Connection ID and, if valid, uses SDK API calls to send a greeting message back to the client.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/apigw-websocket-ack-connect-route

Deploy

sam deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: sam delete.

Created by:

Manasvi Jain

Manasvi Jain

Associate Partner Solutions Architect at AWS

Follow on LinkedIn

Umang Aggarwal

Umang Aggarwal

Technical Account Manager @ AWS

Follow on LinkedIn