top of page

REST(HTTP/S) Vs Websockets(WS/WSS)

Writer's picture: ShivaniShivani

Updated: May 24, 2021

The REST & Websockets are two popular choices for client to server communication.


HTTP, used by REST and WebSocket both are communication protocols used in client-server communication. You can go through this to quickly understand the network communication with the OSI models.


HTTP: A stateless protocol, is unidirectional where the client sends the request and the server sends the response.

HTTP can run on the top of any reliable connection-oriented protocol such as TCP, SCTP. When a client sends HTTP request to the server, a TCP connection is open between the client and server and after getting the response the TCP connection gets terminated, each HTTP request open separate TCP connection to the server, for e.g. if client send 10 requests to the server the 10 separate HTTP connection will be opened. and get closed after getting the response / fallback.


WebSocket: WebSocket is bidirectional, a full-duplex protocol that is used in the same scenario of client-server communication, unlike HTTP it starts from ws:// or wss://. It is a stateful protocol, which means the connection between client and server will keep alive until it is terminated by either party (client or server). After closing the connection by either of the client and server, the connection is terminated from both the end.


WebSocket is another protocol for sending and receiving messages. Both HTTP and WebSockets send messages over a TCP (Transmission Control Protocol) connection, which is a transport-layer standard that ensures streams of bytes, sent over in packets, are delivered reliably and predictably from one computer to another. So, HTTP and WebSockets use the same delivery mechanism at the packet/byte level, but the protocols for structuring the messages are different.

40 views0 comments

Recent Posts

See All
bottom of page