WebSockets · Example Payload

Websocket Handshake Example

Example HTTP Upgrade request and server response for establishing a WebSocket connection per RFC 6455

Full DuplexNetworkingReal-Time CommunicationRFC 6455Web Technology

Websocket Handshake Example is an example object payload from WebSockets, with 5 top-level fields. It illustrates the shape of data this provider's APIs accept or return.

Top-level fields

titledescriptionrequestresponsenotes

Example Payload

websocket-handshake-example.json Raw ↑
{
  "title": "WebSocket Opening Handshake Example",
  "description": "Example HTTP Upgrade request and server response for establishing a WebSocket connection per RFC 6455",
  "request": {
    "method": "GET",
    "url": "http://example.com/chat",
    "httpVersion": "HTTP/1.1",
    "headers": {
      "Host": "example.com",
      "Upgrade": "websocket",
      "Connection": "Upgrade",
      "Sec-WebSocket-Key": "dGhlIHNhbXBsZSBub25jZQ==",
      "Sec-WebSocket-Version": "13",
      "Sec-WebSocket-Protocol": "chat, superchat",
      "Origin": "http://example.com"
    }
  },
  "response": {
    "statusCode": 101,
    "statusText": "Switching Protocols",
    "headers": {
      "Upgrade": "websocket",
      "Connection": "Upgrade",
      "Sec-WebSocket-Accept": "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=",
      "Sec-WebSocket-Protocol": "chat"
    }
  },
  "notes": "The Sec-WebSocket-Accept value is computed by concatenating the Sec-WebSocket-Key with the magic string '258EAFA5-E914-47DA-95CA-C5AB0DC85B11' and taking the SHA-1 hash, base64-encoded."
}