taoensso / sente

Realtime web comms library for Clojure/Script
https://www.taoensso.com/sente
Eclipse Public License 1.0
1.73k stars 193 forks source link

CloudFront + websocket issues #394

Closed avocade closed 2 years ago

avocade commented 2 years ago

We're starting to use sente in development now, but have encountered a roadblock concerning CloudFront (best guess at this moment). We expose our endpoints through CF and an NLB. It seems CF officially supports websockets, but that we need to configure our setup in some way that we at least haven't figured out yet. It seems to strip headers and other nasty things somewhere in the stack, which makes everything fail when running deployed, but works fine when it's local.

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-working-with.websockets.html

Tried searching around for sente-specific issues regarding CF but haven't found any, so thought I'd just hear if you have any pointers for this before we go talk with our (expensive) Solutions Architect at AWS :)

ptaoussanis commented 2 years ago

@avocade Hi Oskar! I'm sorry I haven't used CloudFront with Sente before, so not familiar with this.

For WebSockets to work, you'll need HTTP headers like Upgrade and Connection to work. You might want to check what headers are preserved or stripped.

Besides that, nothing obvious sticks out from your description. I'd start with checking headers, then checking with something like the Chrome network/WebSocket connection tools to see what might be going on.

Best of luck!

avocade commented 2 years ago

Yeah we managed to solve it with some CF config, we needed to explicitly add the correct headers to the approve-list to avoid them being stripped out. I think we made some more changes as well, but I'll see if my colleague Henrik can fill in here, hopefully it can be useful for posterity if others have the same issues :)