How to increase Cloudfront websockets idle timeout?

0

I've connected a Cloudfront in front of my API Gateway with websockets and now every 15 seconds of idle communication on my websockets the connection is closed (probably by cloudfront). When I was accessing the webscocket directly from the API Gateway it was not like that.

profile picture
onhate
已提問 2 個月前檢視次數 171 次
1 個回答
1

Hi there, adding CloudFront in front of your API Gateway, you add an annitional layer which affects the behavior of your websocket connection. In the CloudFront service quotas you have following timeout settings.

NameDefaultAdjustableDescription
Connection timeout per origin10 secNoThe connection timeout per origin (1-10 seconds).
Request timeout30 secYesThe maximum request timeout in seconds.
Origin response timeout (idle timeout)10 minNoThe maximum origin response timeout (idle timeout) in minutes. If CloudFront hasn’t detected any bytes sent from the origin to the client within the past 10 minutes, the connection is assumed to be idle and is closed.
Response timeout per origin60 secYesThe response timeout per origin (1-60 seconds).

The majority are not adjustable and if you keep your CloudFront setup, you'll have to implement something like a Keep-Alive Message. It's quite a common workaround for dealing with websockets timeouts. It basically just sends a periodic ping message from the server to the client or vice versa.

Please verify if it's really a idle timeout which is triggered, because the non-adjustable idle timeout settings would be 10 minutes. Which seems to be more than enough for your use case.

profile pictureAWS
已回答 2 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南