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.

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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인