apigateway WebSocket 使用 postToConnection 在客户端的使用情况

0

【以下的问题经过翻译处理】 你好,我正在尝试在聊天室中使用 apigateway WebSocket。以下用例是否可行?

  1. 加入聊天室。
  2. 从 Lambda 中获取聊天室中用户的连接 ID。
  3. 在客户端使用 postToConnection 直接向聊天室中的用户发送消息。 我知道这是可行的,但我对安全性的角度有些疑虑。直接将 IAM 策略 execute-api:manageconnection 授予用户(我正在使用 Cognito 身份角色)是否可行?
profile picture
EXPERT
asked 6 months ago21 views
1 Answer
0

【以下的回答经过翻译处理】 嗨,

实际上,我建议避免在 WebSocket 方面使用 API Gateway,因为设置起来会变得非常复杂和手动化。你需要使用 Lambda 函数、DynamoDB 来存储会话等等。

我建议参考 Serverlesspresso 工作坊:https://workshop.serverlesscoffee.com/0-introduction/1-overview.html,该工作坊利用 IoT Core,这可能更加强大和可靠,是一个更好的选择。

希望对你有所帮助 ;)

profile picture
EXPERT
answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions