Using Websockets with Python

Anand Tripathi
Pythonistas
Published in
6 min readSep 4, 2020

--

Note: For non-members, this article is also available at https://progressstory.com/tech/python/production-ready-celery-configuration/

WebSocket

Websocket is a communications protocol, providing full-duplex bi-directional communication over a single TCP connection.

To understand Websockets, first, we have to have a clear understanding of HTTP protocol cause both go hand in hand.

HTTP protocol life cycle

HTTP is a protocol which allows the fetching of resources, such as HTML documents. It is the foundation of any data exchange on the Web and it is a client-server protocol, which means requests are initiated by the recipient, usually the Web browser.

HyperText Transfer Protocol is an application layer is a stateless application-level protocol where generally client requests information with headers using actions like GET, POST, PUT … and server sends the response back to the client and the connection is closed.

For every communication, HTTP protocol will open a connection, data exchange then the connection is closed.

If the requirement is to fetch the data continuously from the server. For example…

--

--