Using CloudFront for Long-Lived WebSocket Connections: Any Limitations?

October 22, 2025 5 answers
Asked by TechyTurtle98
I'm running a global service where customers connect through WebSockets. Ideally, we have a 60-second keep-alive, which fits well since CloudFront's idle timeout is 10 minutes. However, I know some devices might not send this keep-alive and could idle for up to 10 minutes. We also evaluated Azure Front Door, which has a hard limit of 4 hours for connections. I'm curious if CloudFront has a similar restriction. I didn't find anything about this in the documentation, aside from the mentioned idle timeout. Has anyone here dealt with WebSockets in a similar application? Any insights or experiences would be really helpful!

Answers

CleverCoder99
AWS AppSync could be really beneficial for your setup if you're looking for something that handles WebSocket connections more smoothly.
Reply to this answer
ReconnectWizard
Why not have the clients just reconnect if they detect a disconnect? I built a system where WebSockets communicated with an ALB. Disconnections weren't too frequent unless there were network issues, and our clients were programmed to reconnect automatically, which worked well for us.
Reply to this answer
ConnectionGuru77
If your WebSocket connection is actively being used, CloudFront wonโ€™t time it out. But if it goes idle, it will eventually disconnect after 10 minutes, and the client will need to reconnect, which honestly isnโ€™t a bad thing.
Reply to this answer
UserFriendly23
It seems like there's a bit of confusion here. CloudFront isn't just for caching; it also offers DDoS protection, which could be useful for your setup.
Reply to this answer
CloudRoadmap12
You could also consider routing your WebSockets through CloudFront to API Gateway which upgrades the connection from HTTPS to WSS. As for the timeout, I've heard the idle limit is 10 minutes, with a max connection time of 2 hours.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions