<html><head><style>pre,code,address {
  margin: 0px;
}
h1,h2,h3,h4,h5,h6 {
  margin-top: 0.2em;
  margin-bottom: 0.2em;
}
ol,ul {
  margin-top: 0em;
  margin-bottom: 0em;
}
blockquote {
  margin-top: 0em;
  margin-bottom: 0em;
}
</style></head><body><div>Hello Guillaume,</div><div><br></div><div>You are right - it should work and :drumroll: it works!</div><div><br></div><div>I've enabled nearly all debug settings and see:</div><div><br></div><pre>    327685 VCL_call       b BACKEND_RESPONSE</pre><pre>    327685 TTL            b VCL -1 3600 0 1750771561 uncacheable</pre><pre>    327685 TTL            b VCL -1 3600 300 1750771561 uncacheable</pre><pre>    327685 VCL_Log        b server_sent_events_vcl_backend_response</pre><pre>    327685 VCL_return     b pass</pre><pre>    327685 VCL_call       b VHA_INTERNAL</pre><pre>    327685 VCL_return     b ok</pre><pre>    327685 Timestamp      b Process: 1750771560.572744 0.837391 0.000332</pre><pre>    327685 BerespHeader   b Content-Encoding: gzip</pre><pre>    327685 BerespHeader   b Vary: Accept-Encoding</pre><pre>    327685 Storage        b mse s0</pre><pre>    327685 Fetch_Body     b 2 chunked stream</pre><pre><pre>    327685 VCL_call       b BACKEND_RESPONSE</pre><pre>    327685 TTL            b VCL -1 3600 0 1750771561 uncacheable</pre><pre>    327685 TTL            b VCL -1 3600 300 1750771561 uncacheable</pre><pre>    327685 VCL_Log        b server_sent_events_vcl_backend_response</pre><pre>    327685 VCL_return     b pass</pre><pre>    327685 VCL_call       b VHA_INTERNAL</pre><pre>    327685 VCL_return     b ok</pre><pre>    327685 Timestamp      b Process: 1750771560.572744 0.837391 0.000332</pre><pre>    327685 BerespHeader   b Content-Encoding: gzip</pre><pre>    327685 BerespHeader   b Vary: Accept-Encoding</pre><pre>    327685 Storage        b mse s0</pre><pre>    327685 Fetch_Body     b 2 chunked stream</pre></pre><div><br></div><div>Varnishd is waiting for compressable bytes and stops the stream. I've added `set beresp.do_gzip = false;` and it works. Current config looks like:</div><div><br></div><div>sub server_sent_events_vcl_recv {</div><pre>    set req.backend_hint = server_sent_events.backend();</pre><pre>    unset req.http.Accept-Encoding;</pre><pre>    return(pass);</pre><pre>}</pre><pre><br></pre><pre>sub server_sent_events_vcl_backend_fetch {</pre><pre>    if (bereq.backend == server_sent_events.backend()) {</pre><pre>        std.log("server_sent_events_vcl_backend_fetch");</pre><pre>        set bereq.first_byte_timeout = 30s;</pre><pre>        set bereq.between_bytes_timeout = 30s;</pre><pre>    }</pre><pre>}</pre><pre><br></pre><pre>sub server_sent_events_vcl_backend_response {</pre><pre>    if (bereq.backend == server_sent_events.backend()) {</pre><pre>        if (beresp.http.content-type == "text/event-stream") {</pre><pre>            std.log("server_sent_events_vcl_backend_response");</pre><pre>            set beresp.do_esi = false;</pre><pre>            set beresp.do_gzip = false;</pre><pre>            set beresp.do_stream = true;</pre><pre>            return (pass);</pre><pre>        }</pre><pre>    }</pre><pre>}</pre><pre><br></pre><div><br></div><div>Thank you</div><div>tom</div><div><br></div><div>Am Dienstag, dem 24.06.2025 um 09:46 +0200 schrieb Guillaume Quintard:</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="auto"><p dir="ltr">Hi Tom,</p><p dir="ltr">I have a hard time believing this doesn't work with pass, but let's check.</p><p dir="ltr">Would you be able to run `varnishlig -g raw` as the transaction is going on ? (You don't want extra traffic otherwise things will be hard to follow)</p><p dir="ltr"><br></p><p dir="ltr">-- </p><div data-smartmail="gmail_signature"><div dir="ltr"><div>Guillaume Quintard<br></div></div></div></div><div><br></div><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, Jun 23, 2025, 08:31 Tom Anheyer | BerlinOnline <<a href="mailto:Tom.Anheyer@berlinonline.de">Tom.Anheyer@berlinonline.de</a>> wrote:<br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><div>Good morning,</div><div><br></div><div>OK, one more. Server-Sent-Events are streaming GET requests. I've tried</div><div><br></div><pre>sub vcl_recv {</pre><pre><span style="white-space:pre-wrap">       </span>…</pre><pre><span style="white-space:pre-wrap">      </span>return(pass);</pre><pre>}</pre><pre><br></pre><pre>sub vcl_backend_fetch {</pre><pre><span style="white-space:pre-wrap">     </span>set bereq.first_byte_timeout = 30s;</pre><pre><span style="white-space:pre-wrap">      </span>set bereq.between_bytes_timeout = 30s;</pre><pre>}</pre><pre><br></pre><pre>sub vcl_backend_response {</pre><pre><span style="white-space:pre-wrap"> </span>set beresp.do_esi = false;</pre><pre><span style="white-space:pre-wrap">       </span>set beresp.do_stream = true;</pre><pre>}</pre><div><br></div><div>without success. The request is forwarded to the SSE server but comes never back and does not show up in varnishlog. Is there any chance to get this work without `pipe`? </div><div><br></div><div>thanks in advance </div><div>tom</div><div><br></div><div>Am Freitag, dem 20.06.2025 um 15:05 +0200 schrieb Guillaume Quintard:</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="auto"><div>Always a pleasure! Let us know if you have any further questions!</div><div><br></div><div data-smartmail="gmail_signature"><div dir="ltr"><div>-- <br></div><div>Guillaume Quintard<br></div></div></div></div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 20, 2025, 13:30 Tom Anheyer | BerlinOnline <<a href="mailto:Tom.Anheyer@berlinonline.de" target="_blank" rel="noreferrer">Tom.Anheyer@berlinonline.de</a>> wrote:<br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><br>Hi Guillaume,<br></div><div><br>thank you for your very quick (as always) and clear answer.<br></div><div><br>tom<br></div><div><br>Am Freitag, dem 20.06.2025 um 11:37 +0200 schrieb Guillaume Quintard:<br>> Hi Tom,<br>> This is a base behavior, so Varnish Enterprise inherits it, but it's present<br>> in Varnish Cache too.<br>> Piping involves foregoing HTTP parsing and just passing all the connection<br>> bytes back and forth. It's possible on HTTP 1.x since there's only at most one<br>> request per connection, but this breaks with HTTP2 multiplexing, so Varnish<br>> does the best thing it can and uses a pass instead.<br>> Interestingly, H/2 didn't plan an upgrade path to websockets (or to anything<br>> else, really) for a relatively sane reason: H/2 requires TLS and TLS has ALPN<br>> that allows you to go to websockets directly, without the upgrade hop.<br>> So, to my (maybe outdated) knowledge of H/2, upgrading to websockets isn't<br>> possible.<br>> Please let me know if I'm not being clear.<br>> -- <br>> Guillaume Quintard<br>> <br>> On Fri, Jun 20, 2025, 11:15 Tom Anheyer | BerlinOnline<br>> <<a href="mailto:Tom.Anheyer@berlinonline.de" rel="noreferrer noreferrer" target="_blank">Tom.Anheyer@berlinonline.de</a>> wrote:<br>> > Hello,<br>> > <br>> > I don't know if this is specific to varnish plus:<br>> > <br>> > <br>> > If I enable pipe-mode for server sent events in vcl_recv this way:<br>> > <br>> > if (…) {<br>> >     set req.http.connection = "close";<br>> >     return(pipe);<br>> > }<br>> > <br>> > the log shows:<br>> > <br>> > -   VCL_return     pipe<br>> > -   VCL_call       HASH<br>> > -   VCL_return     lookup<br>> > -   VCL_Error      vcl_recv{} returns pipe/connect for HTTP/2 request. <br>> > Doing pass.<br>> > -   VCL_call       PASS<br>> > <br>> > <br>> > Is it possible to use server sent events, websockets with http/2 requests?<br>> > <br>> > <br>> > I've o<a href="https://www.google.com/maps/search/pened+a+varnish+software+ticket+but+I+thin?entry=gmail&source=g" target="_blank" rel="noreferrer">pened a varnish software ticket but I thin</a>k that's public interest.<br>> > <br>> > tom  <br>> > <br></div><div><br></div></blockquote></div></blockquote><div><br></div><div><span><pre></pre></span></div></div></blockquote></div></blockquote><div><br></div><div><span><pre>-- <br></pre><pre>Tom Anheyer
Senior Developer

BerlinOnline GmbH
Stefan-Heym-Platz 1
10367 Berlin
Germany

Tel.: +49-30-5771180-62
Fax: +49 30 5771180-95
E-Mail: tom.anheyer@berlinonline.de

berlin.de | berlinonline.net
 
Amtsgericht Berlin-Charlottenburg, HRB 266384
Sitz der Gesellschaft: Berlin, Deutschland
USt.-IdNr.: DE219483549
 
Geschäftsführung: Andreas Mängel, Katrin Dorgeist
Vorsitzender des Aufsichtsrats: Nicolas Zimmer
 

</pre></span></div></body></html>