Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

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


W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.