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.
Related Terms
An API is a contract that lets software systems request approved data or actions from one another through documented endpoints.
GraphQL SubscriptionA GraphQL Subscription is an operation type that streams server events to clients in real time while a connection stays open.
Long PollingLong polling keeps an HTTP request open until the server has new data, giving clients near real-time updates without a persistent socket.
MQTTMQTT is a lightweight publish-subscribe protocol that lets IoT devices exchange topic-based messages through a broker.
SSE (Server-Sent Events)SSE is a web standard for sending one-way live updates from a server to a browser over a long-lived HTTP connection.
WebhookA webhook lets one system automatically send an HTTP request to another when an event occurs, so updates arrive without polling.
WebRTCWebRTC is a real-time communication standard for plugin-free audio, video, and data channels between browsers and mobile apps.
WebSocket ServerA WebSocket server is the backend component that keeps persistent client connections and routes real-time messages.