Channels: Server-Sent Events

Created on 18 Apr 2016  路  6Comments  路  Source: django/channels

Server-Sent Events are kind of the less sexy little cousin to WebSockets. They support a much simpler protocol (no negotiation!) but only do asynchronous server->client.

Could Server Sent Events be added to the channels stack?

Most helpful comment

And for something Channels 2 compatible, there's django-eventstream.

All 6 comments

You can easily do SSE on top of channels. It's about setting content-type to text/event-stream and format correctly the streaming response. I have written a little library implementation on top of channels, last weekend: it's just a matter of cleanup /writing the doc before publishing...

Le 18 avril 2016 16:36:18 GMT+02:00, Jamie Bliss [email protected] a 茅crit :

Server-Sent Events are kind of the less sexy little cousin to
WebSockets. They support a much simpler protocol (no negotiation!) but
only do asynchronous server->client.

Could Server Sent Events be added to the channels stack?


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/andrewgodwin/channels/issues/133

Oh, how fortuitous! Look forward to that.

(To echo flo above, yes, this is entirely possible, SSEs are just a streamed HTTP response, not a new protocol like WebSockets. Channels should already correctly do streaming responses either in the Django style or natively using http.response messages with the more-data flag set.)

Closing this here as it's something better done in a third party library - feel free to post updates here about progress though.

Hey,

I just pushed ssechannels
Did not find a better idea than the decorator based endpoints creation, enables users to not care at all about channels. Pretty untested, probably broken but still proof of concept/example on how to SSE with channels. feedbacks wanted !!

Why is the event name binary but the data a string?

And for something Channels 2 compatible, there's django-eventstream.

Was this page helpful?
0 / 5 - 0 ratings