WebSocket API on AWS API Gateway 2h Connection duration

0

Hi.. I have seen there is a 2h Connection duration limit for Websocket APIs. I know there is a related question https://repost.aws/questions/QUFbNpkJJvTySYuHA7uHQAeQ/extend-websocket-idle-connection-timeout

As this is our first API I am wondering if this would be an acceptable attribute. As we run an IoT Platform and via a websocket API we would like to push incoming data to our customer websocket clients. So they have websocket client which should be 24/7 connected and with the 2h limit we and they have to include logic that no data is lost.

As this should scale very much we don't want to go with an EC2 based solution.

Thanks

rk
已提问 1 年前1645 查看次数
2 回答
0
已接受的回答

Regardless of the solution you eventually choose, you should take into consideration that connections can be closed. It can be by the server, like the case with API Gateway, ir it can be any other network issue that may cause the connection to break.

For this reason, the fact that API Gateway closes the connection every two hours should not be an issue. The client should recreate the connection when it detects that the connection is closed. Also, the server side should save messages in a database if currently there are no open connection to the client. When the connection is established, the server should check if there are any pending messages for that client.

Saying that, did you check the option of using IoT Core? It has a 24 hours connection limit and may be more appropriate for IoT use cases.

profile pictureAWS
专家
Uri
已回答 1 年前
profile picture
专家
已审核 4 个月前
  • Sure, a connection loss can always occur. We are not quite sure if a 2h automatically reconnect cycle time is something common and therefore would be accepted from our customers. But we will start with this. Thanks

0

Given the description of the use case, I would consider using AWS IoT Core and not API Gateway as your backend. Not only AWS IoT Core provides MQTT over Secure Web Socket protocol with connections lasting 24hrs. MQTT client libraries normally manage the reconnection. You also get a fully managed, scalable and secure IoT service.

AWS
专家
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则