caddy: Server Sent Events don't work
1. What version of Caddy are you running (caddy -version)?
0.9.4
2. What are you trying to do?
Proxy SSE through Caddy
3. What is your entire Caddyfile?
:80
gzip {
not /application/events/
}
maxrequestbody 200MB
log stdout
errors stderr
root html/
proxy /application 127.0.0.1:9000 {
transparent
header_upstream X-Real-IP {remote}
header_upstream X-Forwarded-Server {host}
header_upstream X-Forwarded-Host {host}
}
4. How did you run Caddy (give the full command and describe the execution environment)?
caddy
5. What did you expect to see?
I expected my SSE requests to establish a long-running connection that can send data to the client.
6. What did you see instead (give full error messages and/or log)?
The HTTP request does seem to work (returns a 200, and headers), and the connection is kept alive, but SSE frames don’t arrive to the client.
7. How can someone who is starting from scratch reproduce this behavior as minimally as possible?
I’ve tried the https://github.com/jraedisch/go_sse_example to confirm the bug, but streaming does work with that setup. I suspect this error may be specific to interacting with the Java upstream I’m using. nginx, however, works well in the place of caddy, without additional changes to the upstream config. I’m using a python requests script as reference client.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 20 (3 by maintainers)
Commits related to this issue
- proxy: use a new context for the outgoing request fix issue #1355 Signed-off-by: Tw <tw19881113@gmail.com> — committed to tw4452852/caddy by tw4452852 7 years ago
@laszbalo I think it needs some works on server side to implement sse with gzip.
After some investigation, the reason is found. It’s actually a bug in go 1.7…
Firstly, this issue doesn’t happen if you build caddy with go tip which I use, however it happens if you use go 1.7 which @rsdy uses.
The bug is that the chunk reader will expect two more bytes which is
\r\nafter reading a chunk before it returns. So it will read until the offered buffer is full (which is 32K in our case, so big…). Some more details are in this issue.So @rsdy , you could use the newer go (at least contains this commit) to rebuild the caddy, this issue should be fixed then.
Hi @rsdy , I have found the reason. There is a mistake in your CaddyFile, change this line
to
no tail slash!
Also in your https://github.com/rsdy/caddy-dropwizard-sse project, you should disable gzip for
/application/eventsin your CaddyFile