top | item 42601454

(no title)

bluepizza | 1 year ago

My understanding is that long polling has these issues handled by assuming the connection will be regularly dropped.

Clients using mobile phones tend to have their IPs rapidly changed in sequence.

I didn't mention databases, so I can't comment on that point.

discuss

order

josephg|1 year ago

Well, it’s the same in both cases. You need to handle disconnection and reconnection. You need a way to transmit missed messages, if that’s important to you.

But websockets also guarantee in-order delivery, which is never guaranteed by long polling. And websockets play way better with intermediate proxies - since nothing in the middle will buffer the whole response before delivering it. So you get better latency and better wire efficiency. (No http header per message).

bluepizza|1 year ago

That very in order guarantee is the issue. It can't know exactly where the connection died, which means that the client must inform the last time it received an update, and the server must then crawl back a log to find the pending messages and redispatch them.

At this point, long polling seems to carry more benefits, IMHO. WebSockets seem to be excellent for stable conditions, but not quite what we need for mobile.