"Sounds like it's time for a happy middle ground between streaming and short polling, doesn't it? Well, long polling may well fit the bill. The client initiates a request, and if the server has events pending, it sends them and closes the connection, much like short polling. But if the server does not have any events waiting, it holds the connection open until an event occurs, at which point it send the event and closes the connection. The client can then initiate a new connection immediately, since all the waiting is done at the server end.
The obvious benefit to this is that the client can treat the interaction as a simple 'request-response' and wait for it to complete before processing it rather than having to sniff the response as it loads. It works through proxies and is more resilient to connections dropping. And since the server is actively closing connections all the time, the chance of long-lived zombie connections is much reduced. On the negative side, there is a need to create and close many more connections than for a stream, one for each event that is sent (but far fewer than for short polling, because the server no longer has the thankless task of responding to millions of repeated requests with "no updated events available"). Also events may be slightly delayed if they occur in rapid succession while the client is reinitiating a new connection after the last update."
Take a look at http://faye.jcoglan.com/architecture.html.
The Adapter, as implemented by the NodeAdapter and RackAdapter classes, exposes the Server’s interface over HTTP. It is responsible for serializing and deserialzing messages as JSON and accepting connections over various flavours of HTTP transport:
WebSocketYes but is this documented on how to code a long polling mechanism ?
Ok thanks that gives some clearness. Im still not sure though how to implement ( or not implement but setup ) faye so that it will work as I posted in the first message. The server should send data to the client and keep the connection open ( on a reload of the webbrowser) it should instantly resend the data if its not recieved. I think we talked about this earlier but the long polling method should take care of that, right?
Would just setting faye up to use long polling take care of it? as in the following scenario cases:
A) client recieves data ( client = user browsing webapplication written in ror )
B) client gets data send from faye but reloads just at the moment this data is send to the client, resulting in it not recieved ( broken connection ) after the page reloads has been completed the long polling would still have an open connection with faye and the data is re-send. then the connection is closed and a new connection is opened. ( the long polling )
Sorry for beeing so newbie on this Im already reading the cometD server documentation to get a better idea.