-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP server sent events #955
Comments
Coincidentally I was just trying to do this too, in my case I thought HTMX with SSE plus After a bit of poking around, I discovered that Anyhow, I'm not a |
Ha, incidentally I was doing the exact same thing!
That's a good point, I didn't realise httpuv didn't use HTTP/2. As far as I can tell, SSE does not require HTTP/2, but it does make it more usable/feasible. HTTP/1's limited number of connections (6 vs HTTP/2's 100) makes SSE slow. So, I think technically it should be possible right now (albeit hamstrung)? |
I would like it to be possible to serve server sent events (SSE) in plumber. I have been trying to write event-streams using plumber, but have found that whilst I can get the "open" event to fire, I can't send any "message" events because plumber doesn't have a way of sending messages without the return value of the function.
The above results in the connection successfully being opened, and the connection kept alive, but it also means that only the "open" event is sent (and spammed).
SSE are typically easier (for users) to write and use in comparison to websockets, and doesn't require a custom protocol to be handled. Whilst websockets are definitely useful, the bidirectional nature of them is often overkill.
My naive assumption is that the main issue is that
res
doesn't have awrite
function. This is technically different from sockets in that this a uni-directional HTTP connection. I understand that websockets have been looked at (e.g. #723, #419), but websockets are -- as far as I understand -- a slightly different implementation to SSE.I have tried looking through httpuv for a way to do this without plumber, but I've admittedly had difficulty on finding a way to get it to work!
Examples
SSE
Thanks!
The text was updated successfully, but these errors were encountered: