Skip to content

This is a fully-serverless real-time chat example using API Gateway, Lambda and DynamoDB. Messages from one client are broadcast to all other connected clients via WebSockets.

License

Notifications You must be signed in to change notification settings

aws-samples/serverless-websocket-chat

Serverless WebSocket chat example

This is a Serverless project which creates a websocket chat backend. It's quite basic, but supports some standard features including setting a nickname, multiple channels, and broadcasting messages to channel members. The coolest this is that this is entirely serverless and in Python!

Demo

asciicast

Getting started

This can all be deployed with AWS SAM.

$ sam build
$ sam deploy --guided

The final output will be a wss endpoint which you can connect to:

---------------------------------------------------------------------------------
Outputs
---------------------------------------------------------------------------------
Key                 WebSocketURI
Description         The WSS Protocol URI to connect to
Value               wss://abcd123.execute-api.us-west-2.amazonaws.com/Prod

Use wscat to connect and test:

  • Install wscat by just running yarn
  • In two different terminals: ./node_modules/.bin/wscat -c wss://YOUR_WS_ENDPOING
  • Now type a meesage and hit enter...you'll see messages from one window pop up into another.

Commands

  • /name bz - Change your display name to bz
  • /channel random - Change to the random channel. Default channel is general
  • /help

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

This is a fully-serverless real-time chat example using API Gateway, Lambda and DynamoDB. Messages from one client are broadcast to all other connected clients via WebSockets.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages