Reputation: 26354
Why achieving real time connection was difficult with HTTP protocol. As HTTP is implemented over TCP connection which is reliable and continuing the persistent connection should be easier . right?. How Web Sockets solves this persistent connection problem?
Upvotes: 0
Views: 124
Reputation: 596592
Prior to HTTP/2, HTTP/0.9 and HTTP/1.x were just command+response protocols only. A client would send a command, the server would send a reply, done, nothing more. And prior to HTTP/1.1, keeping the TCP connection alive after each response was impossible in HTTP/0.9 and not common practice in HTTP/1.0. HTTP/1.1 standardized that practice.
So it was very difficult to implement any kind of persistent real-time bi-direction communications over HTTP until recent years. Sure, various technologies were devised to try to address this (long polling, server-side pushes, etc), but nothing was really widely accepted and put into common practice across all implementations.
Then WebSockets came along, which was specifically designed for persistent bi-directional communications, in such a way that was easy to add to existing HTTP infrastructures so server admins didn't have to re-invest in new technologies, while maintaining backwards compatibility with older HTTP systems that can't/won't support WebSockets.
Then HTTP/2 came along, which now has server pushes and multiplexing built right in to the HTTP protocol, solving many of the shortcomings of old HTTP versions, and covers some of the use-cases that WebSockets were being used for, but doesn't obsolete Websockets completely.
HTTP has a very long history of evolution to get to where it is today. Evolution takes time.
Upvotes: 2