Server-Sent Events implementation #381

Open
wants to merge 6 commits into
from

Conversation

Projects
None yet
5 participants
@marinho

marinho commented Oct 9, 2011

Hello,

I implemented the the long polling protocol Server-Sent events ( http://dev.w3.org/html5/eventsource/ ) and I guess you like the idea because it is a good, more stable and simpler alternative to WebSockets.

Tested on latest version of Opera, Chrome, Safari and Firefox.

I hope you like.

@lepture

This comment has been minimized.

Show comment Hide comment
@lepture

lepture Oct 10, 2011

Contributor
  1. can server side detect 'close' event. when i refresh my browser, I see waiters increase and never decrease.
  2. can you tell me how to configure nginx for eventsource.
Contributor

lepture commented Oct 10, 2011

  1. can server side detect 'close' event. when i refresh my browser, I see waiters increase and never decrease.
  2. can you tell me how to configure nginx for eventsource.
@marinho

This comment has been minimized.

Show comment Hide comment
@marinho

marinho Oct 10, 2011

Hey lepture :)

I will check about the (1) this evening

About Nginx:

tcp {
upstream play {
server 127.0.0.1:9000; # proxying to your internal Tornado instance
}

server {
listen 2080; # Your external port, I couldn't make it by Nginx using port 80
server_name domain.com;
proxy_pass play;
}
}

marinho commented Oct 10, 2011

Hey lepture :)

I will check about the (1) this evening

About Nginx:

tcp {
upstream play {
server 127.0.0.1:9000; # proxying to your internal Tornado instance
}

server {
listen 2080; # Your external port, I couldn't make it by Nginx using port 80
server_name domain.com;
proxy_pass play;
}
}

@v3ss0n

This comment has been minimized.

Show comment Hide comment
@v3ss0n

v3ss0n Jun 13, 2014

Anything new on this? it would be nice to have on tornado as it is already supported by existing browsers.

v3ss0n commented Jun 13, 2014

Anything new on this? it would be nice to have on tornado as it is already supported by existing browsers.

@bdarnell

This comment has been minimized.

Show comment Hide comment
@bdarnell

bdarnell Jun 13, 2014

Owner

I think that a lot of what's in this PR (e.g. the static live-connection list) is inappropriate for inclusion in Tornado itself. What's left is pretty tiny - just using public APIs to write and flush a simple format over a standard chunked HTTP request. Unlike with websockets, there is no tight coupling to the internals of tornado, so I'm not sure it's worthwhile to include this in the core (as opposed to a separate library or just at the application level).

I like the eventsource protocol because it's so much simpler than websockets, but websockets still have better browser support. I'm not sure which fares better when it comes to getting through proxies.

Owner

bdarnell commented Jun 13, 2014

I think that a lot of what's in this PR (e.g. the static live-connection list) is inappropriate for inclusion in Tornado itself. What's left is pretty tiny - just using public APIs to write and flush a simple format over a standard chunked HTTP request. Unlike with websockets, there is no tight coupling to the internals of tornado, so I'm not sure it's worthwhile to include this in the core (as opposed to a separate library or just at the application level).

I like the eventsource protocol because it's so much simpler than websockets, but websockets still have better browser support. I'm not sure which fares better when it comes to getting through proxies.

@bdarnell bdarnell added multiple and removed multiple labels Jul 16, 2014

@v3ss0n

This comment has been minimized.

Show comment Hide comment
@v3ss0n

v3ss0n Apr 5, 2015

I am now more interested in Evensource , and looking into it. The other implementations are outdated and not working with latest tornado 4.1 , i am going to give this a try and if it fits my needs, it would be nice to have in tornado. (Or i will maintain it as a separate lib).

v3ss0n commented Apr 5, 2015

I am now more interested in Evensource , and looking into it. The other implementations are outdated and not working with latest tornado 4.1 , i am going to give this a try and if it fits my needs, it would be nice to have in tornado. (Or i will maintain it as a separate lib).

@ProtonScott

This comment has been minimized.

Show comment Hide comment
@ProtonScott

ProtonScott Feb 26, 2018

I myself have been very interested this as an alternative to web sockets. I don't think it belongs in the standard tornado library either, but since from my own googling this came up as one of the top 3 results, I want to post this here:

https://gist.github.com/ProtonScott/5aaf6aaa2314a9c46cb40c3253fa8c49

Its a very simple (and I will be definitely updating in the next few days with more code to flesh it out) implementation based on this commit, but with more up-to-date async await syntax where it counts. I intend on testing it heavily over the next week ( this is as of Feb 25 2018). I just hope it helps anyone else looking for a solution to this.

I myself have been very interested this as an alternative to web sockets. I don't think it belongs in the standard tornado library either, but since from my own googling this came up as one of the top 3 results, I want to post this here:

https://gist.github.com/ProtonScott/5aaf6aaa2314a9c46cb40c3253fa8c49

Its a very simple (and I will be definitely updating in the next few days with more code to flesh it out) implementation based on this commit, but with more up-to-date async await syntax where it counts. I intend on testing it heavily over the next week ( this is as of Feb 25 2018). I just hope it helps anyone else looking for a solution to this.

@v3ss0n

This comment has been minimized.

Show comment Hide comment
@v3ss0n

v3ss0n Feb 26, 2018

I made one my own , yours it better since it uses async await.

v3ss0n commented Feb 26, 2018

I made one my own , yours it better since it uses async await.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment