Tutorials References Exercises Videos Menu
Paid Courses Website NEW Pro NEW

AWS Serverless WebSockets Pattern with API Gateway


WebSockets Pattern With API Gateway

WebSockets are an open standard for establishing a persistent connection between a client and a backend server.

The Lambda function handles the request and sends information to the client.

The Lambda function also writes the execution data in the DynamoDB.


How It Works

Using the URL specified by the function, the client connects to the WebSocket API.

At the same time, a Step Functions conducts the "DoWork" step.


Step One

The "DoWork" step implements the order processing inside the Step Functions flow.

When "DoWork" is finished, Step Function runs the "GetConn" task, which queries the DynamoDB table for the WebSocket connection ID.

Then the work result is transmitted to the client via the Step Function notification task using the Websocket API.


Step Two

"DoWork" step implements the order processing inside Step Functions flow.

When "DoWork" is finished, Step Function runs the "GetConn" task.

The "GetConn" task searches the DynamoDB table for the WebSocket connection ID.

The result is then transmitted to the client via the Step Function notification task by using the Websocket API.

This pattern features a synchronous integration of Lambda and API Gateway.


WebSockets Pattern with API Gateway Video

W3schools.com collaborates with Amazon Web Services to deliver digital training content to our students.


Advantage of WebSockets

The WebSockets is a two-way connection between the server and the client.

It is supported on both web and mobile platforms.

You don't need to worry about the network settings to connect outside using WebSockets.

You don't need to host a separate endpoint for WebSockets.

Related reads:

Creating, Deploying, and Invoking a WebSocket API in Amazon API Gateway

AWS Serverless Exercises

Test Yourself With Exercises

Exercise:

Fill in the blanks

WebSockets are an open standard for establishing a persistent connection between a  and a 

Start the Exercise