2 ms·
How would you implement something like push in HTTP for example? I remember, that XMPP had to come up with some hacks (BOSH[1]) to do it over HTTP. 1. https://
by shmerl 10y ago
How would you implement something like push in HTTP for example? I remember, that XMPP had to come up with some hacks (BOSH[1]) to do it over HTTP.
1. https://en.wikipedia.org/wiki/BOSH_(protocol) https://en.wikipedia.org/wiki/BOSH_(protocol)
- jkarneges 10y agoStreaming (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 10y 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 10y 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).