WebSocket
ওয়েবসকেট
HTTP upgrade দিয়ে শুরু হওয়া single TCP connection-এর full-duplex message channel, server push-এর প্রধান পথ।
HTTP request-এ Upgrade: websocket; server রাজি হলে
101 Switching Protocols — তারপর ওই TCP connection HTTP থেকে
WebSocket frame-এর channel। Full-duplex: polling-এর অপেক্ষার
বদলে দুই দিকেই যখন খুশি বার্তা।
GET /chat HTTP/1.1
Host: example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Version: 13
বৈশিষ্ট্য
- শুরুটা HTTP, তাই port 80/443 — proxy/firewall পার হওয়া সহজ
ws://plain,wss://TLS-এর ভেতরে- Message frame-ভিত্তিক; HTTP-র মতো request/response semantics নেই
- Built-in ping/pong keepalive, fragmentation
Reverse proxy-র ফাঁদ — Upgrade/Connection header forward
না করলে handshake আটকে যায়; idle timeout-এ proxy connection
কেটে দিতে পারে। Chat, live dashboard, multiplayer game — এদেরই
ঘরের জিনিস; one-way push-এর জন্য SSE-ও যথেষ্ট হতে পারে।