SSE collapsing help -- my connections are dropped early

Hello again,
I’m testing SSE request collapsing but getting unexpected results.
When I connect to my API’s SSE url, it stays alive for the configured time (2 minutes) but when I connect to the same API via fastly, it drops at about 10 seconds after the initial response.

I’m using curl to test like this

curl -v -N --http2 -H "Accept:text/event-stream" https://my-url

When Fastly closes the connection i’m getting

* HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)
* Connection #0 to host cdn.myhostname left intact
curl: (92) HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)

whereas when my api cuts off the connection curl

* Connection #0 to host api.myhostname left intact

These are the relevant headers i’m returning

< cache-control: no-cache, s-maxage=118
< vary: Authorization, x-prefab-start-at-id, Last-Event-ID
< date: Mon, 29 Jul 2024 21:04:11 GMT
< content-type: text/event-stream

I have set beresp.do_stream = true; set in a vcl snippet in the fetch phase

Thank you!

Edited:
The behavior sounds like the too-large-object failure mode described in Failure modes with large files but the object I’m sending in this test is 51KB and it still happens testing with a much smaller object

I took a look at the fastly origin settings and noticed between_bytes_timeout and first_byte_timeout.

My SSE starts with a :welcome comment so there is immediate content – so i tried raising between_bytes_timeout from 10000 ms to a much bigger number, and now the session stays alive.

Are there any docs that indicate this setting is worth a look if you don’t have a very chatty SSE API and you want to do collapsing? Seems like a good thing to keep in mind when balancing keep-alive timings vs fastly settings.

Edit: at 1000000 ms between_bytes_timeout (16 min) the connection still drops right around a minute – still an improvement over where we started

1 Like

I have a specific doc in mind where this could be a useful addition. I’ll file a ticket with the team.