Ravi Sir's Cards › AWS
WebSocket chat room
This revision card explains WebSocket chat room. It starts from the need that whatsApp Web and live support need push. Refreshing HTTP every second wastes battery and still feels laggy. It describes API Gateway WebSocket API keeps a connection. Routes $connect, $disconnect, and sendMessage hit Lambda. DynamoDB stores connectionIds and messages. The how-to section covers how to create WebSocket API, three routes to Lambda, table PK connectionId, tiny HTML client with new WebSocket(wssURL). An example on the card is two browser tabs connect; one sends hello; both see the message via Management API PostToConnection.
Read card text
What this card says
Why do we need it?
WhatsApp Web and live support need push. Refreshing HTTP every second wastes battery and still feels laggy.
What is it?
API Gateway WebSocket API keeps a connection. Routes $connect, $disconnect, and sendMessage hit Lambda. DynamoDB stores connectionIds and messages.
How to do it
Create WebSocket API, three routes to Lambda, table PK connectionId, tiny HTML client with new WebSocket(wssURL).
$connect
Example
Two browser tabs connect; one sends hello; both see the message via Management API PostToConnection.