Skip to content

Instantly share code, notes, and snippets.

@nilz3ro
Last active February 27, 2016 04:36
Show Gist options
  • Save nilz3ro/18deddee800d571814fd to your computer and use it in GitHub Desktop.
Save nilz3ro/18deddee800d571814fd to your computer and use it in GitHub Desktop.
WebSocket Notes

Notes

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
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment