WebSocket
Definition
WebSocket enables a persistent, bidirectional message exchange between client and server.
WebSocket is a connection technology where client and server can send messages in both directions after the connection is established. The browser does not need to start a new request for each update. The application itself defines how messages are structured and processed.
Simply explained
Instead of constantly asking for new messages, you keep a connection open. Both sides can communicate something over it.
Why it matters in practice
WebSocket is suitable for ongoing status messages and interactive applications where frequent updates should be visible promptly.
Example from business
Possible example: An internal dashboard receives new processing statuses of orders via a WebSocket connection as soon as the server provides them.
Limits and pitfalls
- Open connections can drop. Reconnection, permissions, and message volumes require their own rules; the classic browser API does not automatically throttle excessive message inflow.
Origin & history
WebSocket complements the request-oriented web with a persistent connection over which both sides can exchange messages without continuous polling.
Use in mid-sized companies
- Operations can implement live status displays and define how the interface reacts to connection loss or outdated data.
Frequently asked questions
Does WebSocket replace all HTTP requests?
No. For many normal page loads and occasional data queries, HTTP remains appropriate; WebSocket serves a different communication need.
Sources
- o. J., The WebSocket API · MDN Web Docs, o. J., The WebSocket API
Editorially reviewed on: