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 Answer
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
answered a month 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