Can Server sent events (sse) work with AWS Cloudfront?

Viewed 1731

Is there a way to make sse (server sent events) work using Cloudfront?

I know they announced websockets support few years ago but I can not find any reference or cases related to using sse communication through Cloudfront.

I did a test and the client response ends with 504 Gateway Time-out after a minute approx.

2 Answers

Websockets works with AWS API Gateway. You can use AppSync (GraphQL) Subscriptions also. CloudFront can’t send anything himself.

AWS resources are linked with event bridge (Basically async way to trigger an event) and its stateless so it is not possible. The only way is you have to deploy your app in some sort of web container using which you can achieve your expected behaviour. Another way is you can use AWS API Gateways's websocket open the connection (Full duplex) and back and forth transafer what ever data you want.

Related