slact / nchan

Fast, horizontally scalable, multiprocess pub/sub queuing server and proxy for HTTP, long-polling, Websockets and EventSource (SSE), powered by Nginx.
https://nchan.io/
Other
3.01k stars 293 forks source link

EventSource is not functioning when using http2 #576

Open Peter-Sh opened 4 years ago

Peter-Sh commented 4 years ago

Subscriber connections to EventSource are unexpectedly closed when http2 protocol is used.

Nginx logs

2020/06/13 10:07:48 [error] 6#6: *1 output on closed stream, client: 172.17.0.1, server: localhost, request: "GET /subscribe/ HTTP/2.0", host: "localhost:3006"
172.17.0.1 - - [13/Jun/2020:10:07:48 +0000] "GET /subscribe/ HTTP/2.0" 400 0 "-" "curl/7.52.1" "-"

I've build docker environment for reproducing this behaviour and wrote detailed description here: https://github.com/Peter-Sh/nchan-eventsource-http2-issue

slact commented 4 years ago

Thanks for the detailed report, I'm looking into this.

jallaix commented 4 years ago

Hi, just a word to say I have no problem with HTTP2. My subscribers successfully receive server-sent events (nchan 1.2.7).

phiresky commented 3 years ago

I have the same issue. Both with nginx 1.18 and 1.19.

It also sometimes logs MEMSTORE:01: tried adding WAITING chanhead 000055EB98902400 general/broadcast to chanhead_gc. why?

phiresky commented 3 years ago

More info:

The server responds with a 204 No Content response, but a 400 response is logged.

With nginx 1.16.1 it is also broken. With nginx 1.14.2 it works. So I guess this is a regression. I read somewhere that nchan uses 204 responses to make nginx keep the connection alive. Maybe they changed how this works?