是否可以使用 AWS 以无服务器方式订阅 WebSocket? [英] Is it possible to subscribe to a WebSocket in a serverless fashion using AWS?
问题描述
一个网站提供了一个 websocket 来获取实时数据.我正在尝试将从 websocket 接收到的数据记录在 DynamoDB 表中,作为无服务器应用程序的数据源.他们如何使用 websocket 的例子是一些使用 socket.io-client 的 Node.JS 代码.作为 JavaScript,我想使用 AWS Lambda 函数,但它们并不是为了持续运行.是否有 AWS 服务来处理此类订阅?我不想为此目的而制作一个小型 EC2 实例来运行一个小型应用程序.
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.
我看过的东西:
- Lambda 函数 - 仅适用于短期执行而非长时间运行的任务.
- SNS 订阅 - 据我所知,这需要订阅 SNS 发布者.
- Kinesis Stream - 要求生产者使用 Streams PUT API.
任何帮助将不胜感激!
推荐答案
你们难道没看到他不想做服务器,而是想做客户端吗?
Can't you guys see that he does not want to be server, but the client instead?
因此,如果我们谈论成为客户端,那么到目前为止,在 Amazon AWS 上还没有解决方案/服务,它是无服务器的,并且仅在套接字的生存时间(从连接到断开连接)内保持活动状态.
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.
这篇关于是否可以使用 AWS 以无服务器方式订阅 WebSocket?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!