Is it possible to build a function in AWS Lambda that creates a websocket and send data to subscribed applications?
Something like this:
John has the app SuperPhotoApp opened in his phone but decides to use the desktop browser to upload a photo to the SuperPhotoApp service (a S3 Bucket), this event executes a Lambda function that creates a socket.io server and pushes the update to all subscribers, his phone had the app opened so the app automatically updates with the new photo.
This is something that can be done with push notifications or Amazon SNS, but what if I need real-time behaviour for example an online game where I need to update the position of a character.
If this is not possible with Lambda, is there any solution where I can update my opened app using a desktop browser?
Amazon EC2 is the only option? I've read that it has problems with scaling, that's why I'm commenting on Lambda.
A WebSocket API in API Gateway is a collection of WebSocket routes that are integrated with backend HTTP endpoints, Lambda functions, or other AWS services. You can use API Gateway features to help you with all aspects of the API lifecycle, from creation through monitoring your production APIs.
As said before, Socket.IO can fall back to technologies other than WebSockets when the client doesn't support it. If (for some reason) a WebSocket connection drops, it will not automatically reconnect… but guess what? Socket.IO handles that for you! Socket.IO APIs are built to be easier to work with.
Socket.IO is a JavaScript library for realtime web applications. It enables realtime, bi-directional communication between web clients and server. It has two parts: a client-side library that runs in the browser, and a server-side library for node.
Recently AWS released support of WebSockets for IoT service. It is very easy to use as Pub/Sub message system for serverless web applications. You can post new messages from AWS lambda function
via http post request
and receive them as websocket messages on a client.
I wrote a small npm package that handles websocket connection to MQTT server from the front-end app. Check out aws-mqtt-client
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With