Skip to content
Example repo for websockets
JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
deployHooks
src
.gitignore
.stackery-config.yaml
README.md
template.yaml

README.md

Websocket Example

Why Websockets???

  • Websockets are helpful when you need to have two way direction between an application and client
  • Use case in this example: receiving a web notification when an item is removed or put into an s3 bucket
  • Very useful when making an http call that takes a while to process for example using AWS Polly or AWS translate
  • Very common use case is for chat applications

Architecture

Image

Directions to Run

  1. Deploy the app. It's recommended to use Stackery
  2. Find your websocket URL, create a file called config.js at src/frontend/src/config.js, and add the following:
export default {
  connection: < WEBSOCKET URL HERE STARTING WITH wss: >
};
  1. cd src/frontend/src && npm install && npm start
  2. Open browser console
  3. Add and remove items from the s3 bucket via the AWS console and see the messages in your browser console
  4. Can also hit the 'send message' button in the web UI to send a message and get an echoed response
  5. Open up the frontend on multiple browsers and/or use wscat in on the command line and see the messages broadcast to all clients

Additional resources

You can’t perform that action at this time.