Is it possible to subscribe to a WebSocket in a serverless fashion using AWS?
Solution 1
Can't you guys see that he does not want to be server, but the client instead?
So, if we are talking about to be the client, there's not solution/service, until now, on Amazon AWS that is serverless and stay alive just for the socket's living time (from connect to disconnect).
Unfortunately, I think we are left to work with instances for this kind of scenario.
Solution 2
API Gateway now supports WebSockets where you can handle the events in Lambda and also respond in a simplified way. For more information refer Announcing WebSocket APIs in Amazon API Gateway
Also there are two other services in AWS you can use to achieve this,
- AWS IOT Websockets:- The idea is clients will subscribe to IOT Topics and from Lambda it will push messages to client.
- AWS AppSync (Newly Introduced):- Having a layer in between Lambda and DynamoDB which will provide WebSocket support.
Note: You might need to request for the preview of AppSync at the moment.
Braydon
Work in IT. Really interested in cloud and serverless applications.
Updated on June 15, 2022Comments
-
Braydon over 1 year
A website offers a websocket to get real-time data from. I'm trying to record data received from the websocket in a DynamoDB table for a data source for a serverless application. Their example of how to use the websocket is some Node.JS code using socket.io-client. Being JavaScript I thought to use an AWS Lambda function but they are not purposed to run constantly. Is there an AWS service to handle this sort of subscription? I don't want to make a small EC2 instance to run a tiny application just for this purpose.
Things I've looked at:
- Lambda functions - Only for short executions not long running tasks.
- SNS subscriptions - From what I understand this needs to subscribe to an SNS publisher.
- Kinesis Stream - Requires producer to use Streams PUT API.
Any help would be greatly appreciated!
-
Filippo Loddo over 5 yearsIs there an example on how to implement the IoT websocket? I just want to subscribe to a data stream and store the data received in S3. I haven't found any useful examples on the AWS documentation
-
Alex Hague almost 5 yearsIt's worth noting that AWS has now released support for WebSockets in API Gateway - see aws.amazon.com/blogs/compute/…
-
Warren Parad almost 3 yearsThis is no longer true, downvoting.
-
Ashan almost 3 years@WarrenParad Thanks for notifying. Modified the answer accordingly.
-
soulmachine over 2 yearsonly this answer makes sense, I doubt all other answers are posted by bots
-
Marek Kowalski over 1 yearThe question is about consuming Websocket service as a client. The information you listed is about how to create a Websocket service - the server-side of it.