WebSocket Protocol is an Application Layer protocol that enables a client and server to send and receive messages simultaneously through a full duplex stream over one TCP/IP connection on port 80 or 443.
Default WebSocket protocol client request, and server response:
- send HTTP/1.1 GET
GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw== Sec-WebSocket-Protocol: chat, superchat Sec-WebSocket-Version: 13 Origin: http://example.com
- Server responds with HTTP/1.1 code 101 Switching Protocols
HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk= Sec-WebSocket-Protocol: chat