Server-Sent Events/Evensource

131 views
Skip to first unread message

Ilkka Huotari

unread,
Feb 10, 2011, 4:23:21 PM2/10/11
to play-fr...@googlegroups.com
Any ideas if this could work with Play? I'm in the impression that it needs some support from the web server. I'm not talking about websockets, but its simpler version - eventsource (one directional, from server to browser) .


There is a blog post with some discussion, it can give someone some more ideas where to go, but it didn't take me very far: http://jabberwocky.eu/2011/02/02/html5-pubsub-and-browser-push/


Message has been deleted
Message has been deleted

Ilkka Huotari

unread,
Feb 11, 2011, 7:03:19 PM2/11/11
to play-fr...@googlegroups.com
OK, here's a little bit more info and questions. The text below may contain something stupid, so please be aware. I'm just getting to know this stuff.

Basically the web server and the framework already support this. What I would like to know is how to do this effectively, to support a lot of simultaneous users. 

One could think this as a sort of a "long polling" mechanism. With that in mind I try to describe the problem: 

One way to implement this on the server side seems to be (pseudo code in a true BASIC fashion) :
10 accept a http request (a controller method is called at this point)
20 a loop starts here
30 do await/waitfor/something similar to wait for new data to send (one could probably use actors to wait for the data)
40 send some data to the client
50 goto line 20

Now... my concern is: 
- Does every http request take a dedicated thread? 
- If so, this may not scale very well? 
- Would this be a limitation in the language/virtual machine/web server or where? 
- Could this be done in a way that only one thread would be used for all the connections, and at the point of "await" (line 30) this particular thread could handle another incoming connection?
- Am I missing something here? 

So.. a lot of questions/confusion. Hope someone got something out of this and can write some advice? Thanks.
Message has been deleted

Ilkka Huotari

unread,
Feb 11, 2011, 7:49:45 PM2/11/11
to play-fr...@googlegroups.com
Note that actually this isn't quite like a standard long polling, the connection is never dropped (until the client leaves).

Guillaume Bort

unread,
Feb 12, 2011, 2:46:51 PM2/12/11
to play-fr...@googlegroups.com
If you use waitFor in 1.1 or await in current trunk and 1.2 the thread will be suspended and reused to serve other requests until the Future completes. 

On 12 févr. 2011, at 01:49, Ilkka Huotari <ilk...@gmail.com> wrote:

Note that actually this isn't quite like a standard long polling, the connection is never dropped (until the client leaves).

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

Ilkka Huotari

unread,
Feb 12, 2011, 4:19:37 PM2/12/11
to play-fr...@googlegroups.com
Hmm, Promise might not be the right tool for this after all, as it's not really a "computation" what is waited for, but a message from somewhere else. I suspect actors might be better. 

Would Akka actors or some other actors release/re-use the thread too? 
Reply all
Reply to author
Forward
0 new messages