Skip to content

WebSocket Lifecycle

JayaShankar Mangina edited this page Feb 1, 2022 · 1 revision

But we can achieve two-way communication between the server and the client using the WebSocket Protocol. A WebSocket is a two-way communication protocol between the server and the client. It's a low-level protocol that specifies how to send messages without providing any extra information about the incoming messages. Our UI Client (which is a browser) connects to the message broker via the STOMP Protocol, which is a simple text-oriented messaging protocol. It specifies a protocol for communicating with clients and servers using message semantics.

Here's how it works.

  1. The client establishes a WebSocket connection through a process known as the WebSocket handshake. This process starts with the client sending a regular HTTP request to the server. An Upgrade header is included in this request that informs the server that the client wishes to establish a WebSocket connection.
  2. If the server supports the WebSocket protocol, it agrees to the upgrade and communicates this through an Upgrade header in the response.
  3. Now that the handshake is complete the initial HTTP connection is replaced by a WebSocket connection that uses the same underlying TCP/IP connection. At this point either party can starting sending data.

Clone this wiki locally