Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 869
Braydon Avatar asked Dec 13 '17 04:12

Braydon


People also ask

Can I use WebSockets in AWS?

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.

Does AWS WAF support WebSocket?

As of now, WAF cannot be used with a WebSocket API in Amazon API Gateway.

How do I listen to WebSockets in react?

Need help at client level to connect to 'http://localhost:3001/ws' to establish and listen connection. If you have no a lot understanding of sockets (like me), I suggest to use socket.io package => npmjs.com/package/socket.io It's a wrapper for websockets.


1 Answers

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.

like image 198
Marco Silva Avatar answered Sep 20 '22 01:09

Marco Silva