Skip to main content

What is WebSocket?

Klaxoon. avatar
Written by Klaxoon.
Updated yesterday

WebSocket is a network communication protocol that allows an interactive, two-way connection between a web browser (or client application) and a server. Unlike traditional HTTP, which operates on a request/response model, WebSocket allows both parties to exchange data at any time, in real-time, without having to open a new connection for each exchange.

Operation

When the WebSocket connection is initiated, it starts with a typical HTTP request, called a "handshake." If the server accepts the connection, the protocol then "switches" to WebSocket. From this point on, the connection remains open:

  • The server can send data to the client at any time (push).

  • The client can also send data to the server without waiting for a response to a previous request.

This mode of communication is particularly suitable for applications requiring real-time exchanges, such as collaborative tools such as Klaxoon, instant messaging, online games or trading platforms.

Benefits

  • Real-time : Messages are transmitted instantly, with no delays related to opening/closing multiple connections.

  • Reduced network load : A single persistent connection is used, which reduces the overhead of multiple HTTP requests.

  • Bidirectionality : The server and the client can send messages to each other at any time.

Examples of use

  • Online collaboration (Klaxoon, Google Docs, etc.)

  • Chats and instant messengers

  • Online multiplayer games

  • Live financial or sports data streaming

Prerequisite

To work, WebSocket must be authorized by the user's network. Some firewalls or proxies can block this protocol, which can prevent applications that depend on it from working properly.

Find all the information you need to authorize WebSocket in the following article: What are the network requirements for optimal operation of Klaxoon?

Did this answer your question?