What is WebSocket?

Turkish: WebSocket

WebSocket starts with an HTTP upgrade and provides persistent, bidirectional real-time messaging between client and server.

What is WebSocket?

WebSocket is a protocol that enables bidirectional messaging over one persistent connection between a browser and a server. In classic HTTP, the client sends a request and the server replies. With WebSocket, the connection stays open so either side can send a message when needed.

How It Works

The connection starts with an HTTP handshake and is upgraded to the WebSocket protocol through the Upgrade: websocket header. After that, data moves in frames. Keeping the connection alive, authenticating users, authorizing channels, reconnecting, and scaling are application architecture concerns.

API calls work well for individual request-response flows. A webhook sends a callback to another system when an event occurs. WebSocket is better when the user and server need a continuous low-latency channel.

Business Use

Live chat, support screens, instant notifications, financial price feeds, courier location tracking, multiplayer games, and operations dashboards are common WebSocket use cases. A support agent seeing a new customer message without refreshing the page is a typical example.

Not every real-time feature needs WebSocket. For infrequent notifications, polling or server-sent events may be simpler. If WebSocket is chosen, horizontal scaling, connection limits, and message ordering should be designed early.