Serverless WebSockets

David (drbh) Holtz
2 min readJan 17, 2019

--

Yep, you heard me right.

AWS at it again, with a great tool — that fills real world computer needs and will likely fly under the radar for some time.

API Gateway WebSocket API

Is a tool that allows you to create persisted two way connections without a server! Essentially for each action, connect, disconnect… you trigger a lambda function. This function then reads the WS message and broadcasts message back to that channel with the intended information

The Demo

The Code

Below i’ve shared the Python code that handles the state and websocket calls. This function triggers on connect, disconnect and on explicit messages. I haven’t included the game logic code (written in Golang) since it is verbose and not very extendable. The below code is messy but is a great foundation for setting up lambda functions that interact with API Gateways WebSocket calls.

Thanks for getting through this adventure with me. Please show support and 👏 (clap) for this article.Remember you can clap up to 50 times, and clapping for this article would be really helpful in the Medium algorithm.Any support is greatly appreciated ❤️Also, please answer the questions and add to the discussion below

--

--

David (drbh) Holtz
David (drbh) Holtz

Written by David (drbh) Holtz

Prompt/Software Engineer | 🦺 always building 🪛

No responses yet