Server Sent Events

45 views
Skip to first unread message

Timothy Perrett

unread,
Dec 27, 2014, 1:41:49 AM12/27/14
to unfilter...@googlegroups.com
Hey gang,

Stumbled across this:

And implemented it in a toy i'm building over the holidays (plus a little upgrading to work with 8.4). However, given:

λ curl -vG --no-buffer -H "Accept: text/event-stream" http://127.0.0.1:8080/servertime

The connection does not stay open, it simply serves a single response and closes the connection. How do I keep the connection open and have it properly stream?

Cheers, Tim


Doug Tangren

unread,
Dec 27, 2014, 11:04:21 AM12/27/14
to unfilter...@googlegroups.com

If you dig into
https://github.com/unfiltered/unfiltered/blob/0.8.4/netty/src/main/scala/bindings.scala you'll find a class called requestbinding. It's what req refers to in that gist.

If you want to stream msgs you can call underlying I think which gives you a ref to recieved message which should allow you to gain access to the netty channel which you can write msgs to. It's up to you to close the connection. Could probably do that with a listener on the channels close future.

Hope that helps. I'm in rural country with family for the holidays and only a mobile phone so typing up that in a new gist is a little awkward on my phone :)

> Cheers, Tim
>
>
> --
> You received this message because you are subscribed to the Google Groups "Unfiltered" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to unfiltered-sca...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Timothy Perrett

unread,
Dec 28, 2014, 12:16:57 AM12/28/14
to unfilter...@googlegroups.com
Thanks Doug - i'm also out for the holidays, so i'll take a look in the coming days and let you know!

Cheers

Timothy Perrett

unread,
Dec 29, 2014, 6:00:49 PM12/29/14
to unfilter...@googlegroups.com
So I tried writing directly to the channel, but im really not familiar with how Netty works and how its bound to unfiltered. 

Blindly writing to the channel doesn't work, and even something more sophisticated using a responder that writes to the output stream of the channel didn't work either. It's not as straight forward as one would probably like :-( 

Basically I have a scalaz.stream.Process and I want to stream it via HTTP :-)

-- T
Reply all
Reply to author
Forward
0 new messages