WebSocket Story

Julio Anthony Leonard
2 min readNov 8, 2018

In the past, creating an app that needs live updates like a game or chatting to need to have bi-directional communication between client and server. This abuse the HTTP poll to communicate to the server and to receive incoming connections.

This had created several problems such as:

  • The server needs to use a forced number of different TCP connections, 1 is for accepting the notification and one is for sending information to the client
  • Each client-server communication will have HTTP header thus creating big overhead
  • The client-side script will need to maintain the mapping from the outgoing connection

One of the solutions is to use a single TCP for one connection thus maintaining both sides of the direction. This is what WebSocket provide, combined with WebSocket API (WSAPI), this will handle the pool of communication between web-page and a remote server.

To look it closely, this diagram explains better on how WebSocket helps to transform from a large chunk of request each time a communication between client and server unto a single connection stream.

Source: https://www.fullstackpython.com/websockets.html

This example shows that every time the web browser need new data, it will need to check every request with a large chunk of HTML header to make things work. Thus this created a higher latency in real time.

Source: https://www.fullstackpython.com/websockets.html

Web Socket tries to handle this thing by making only one request and establish one connection thus server and the client can push data to each other in real time without creating additional request because they already know each other.

If you find something I should add on this article more, feel free to tell me

--

--