Is it possible to subscribe to a WebSocket in a serverless fashion using AWS?

11,599

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

enter image description here

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.

enter image description here

  • 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.

Share:
11,599
Braydon
Author by

Braydon

Work in IT. Really interested in cloud and serverless applications.

Updated on June 15, 2022

Comments

  • Braydon
    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
    Filippo Loddo over 5 years
    Is 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
    Alex Hague almost 5 years
    It's worth noting that AWS has now released support for WebSockets in API Gateway - see aws.amazon.com/blogs/compute/…
  • Warren Parad
    Warren Parad almost 3 years
    This is no longer true, downvoting.
  • Ashan
    Ashan almost 3 years
    @WarrenParad Thanks for notifying. Modified the answer accordingly.
  • soulmachine
    soulmachine over 2 years
    only this answer makes sense, I doubt all other answers are posted by bots
  • Marek Kowalski
    Marek Kowalski over 1 year
    The 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.