WebSocket Protocol https://tools.ietf.org/html/rfc6455 ws:// or wss:// HTTP is strictly a client-server protocol How to do bidirectional communication? traditional: "long polling" 2 phases: (1) HTTP upgrade GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== Sec-WebSocket-Protocol: chat, superchat Sec-WebSocket-Version: 13 HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= Sec-WebSocket-Protocol: chat (2) arbitrary, bidirectional data exchange exchange "messages", split in "frames" Network considerations ====================== NAT (Network Address Translation) (most) clients have private IP addresses (192.168.x.y, 10.x.y.z, etc.) cannot connect directly to client Proxy (control outbound traffic, may be caching)