Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fix the websocket limits for `Connection duration for WebSocket API: 2 hours`

I am using API Gateway websocket connection and I have read this limits:

https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html

It says the Connection duration for WebSocket API limits is 2 hours. Does this mean I can't keep the connection connected for more than 2 hours? If yes, what is the workaround for that? Should I have to re-establish the connection every 2 hours in order to keep it connected?

like image 688
Joey Yi Zhao Avatar asked May 23 '20 12:05

Joey Yi Zhao


People also ask

How long will a WebSocket stay open?

However, the connection between a client and your WebSocket app closes when no traffic is sent between them for 60 seconds.

How does WebSocket keep connection open?

If the Pong frame isn't received, websockets considers the connection broken and closes it. This mechanism serves two purposes: It creates a trickle of traffic so that the TCP connection isn't idle and network infrastructure along the path keeps it open (“keepalive”).


1 Answers

I resolved this issue by implementing reconnection mechanism from client. Client simply reconnects to the server once the connection is dropped by API gateway after 2 hours. Found this as a recommended solution at multiple places.

like image 144
Ishwar Avatar answered Oct 25 '22 17:10

Ishwar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!