शब्दकोश · वेब डेवलपमेंट

WebSocket

WebSocket is a protocol that opens a persistent two-way connection between browser and server, allowing instant messages without repeated HTTP requests.

अपडेट: अक्टूबर 6, 2026

WebSocket is a communication protocol that starts as an HTTP request and upgrades into a long-lived, full-duplex connection, so either side can send messages at any time. URLs use the ws:// or secure wss:// scheme.

Why it matters

Chat, live dashboards, multiplayer games and notifications need low-latency updates, and polling with repeated requests wastes bandwidth. Long-lived connections create operational demands, though: proxies and load balancers must support the upgrade and have suitable idle timeouts, and each open connection uses server memory. Monitoring should include a test that actually opens the connection, not just a check that the homepage returns 200.

Example

const ws = new WebSocket('wss://example.com/live');
ws.onmessage = (e) => console.log('update:', e.data);
ws.onopen = () => ws.send('subscribe:orders');

The handshake response is status 101 Switching Protocols.

Common mistakes

  • Using plain ws:// on an HTTPS page, which browsers block as mixed content.
  • Not sending periodic pings, so idle proxies close the connection.
  • Forgetting reconnection logic with backoff.

Get notified when this term updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.