3 ms·
Streaming (server trickles out a response that never ends) or long-polling (server intentionally waits before sending a full response) work very well for pushin
by jkarneges 9y ago
Streaming (server trickles out a response that never ends) or long-polling (server intentionally waits before sending a full response) work very well for pushing data.
BOSH uses long-polling, and as someone from the XMPP community I'll admit it's a bit of a hack around HTTP, mainly because it's stateful.
However, it's entirely possible to have RESTful/stateless long-polling, for example in Dropbox's API:
https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-longpoll https://www.dropbox.com/developers/documentation/http/docume...
- shmerl 9y agoBy the way, can't WebSockets be used to solve this? It would still use HTTP for initial connection, but essentially can work without relying on streaming and polling hacks. And it's not really limited to usage in browsers.
- jkarneges 9y agoYup, WebSockets could certainly be used for push. I think the choice of HTTP vs WebSockets comes down to architecture style. WebSockets are optimized for bidirectional communication with a specific remote server. In other words, something about the service makes it better if client I/O is sticky, maybe due to an in-memory session. HTTP can make more sense in a stateless architecture, where GETs and POSTs could potentially go to different servers in the cluster. Of course, one could use WebSockets statelessly too (have no messages depend on past messages for context).