WebSocket Subprotocol Reference

IANA-registered WebSocket Sec-WebSocket-Protocol subprotocol names with description.

Searchable IANA WebSocket subprotocol registry — Sec-WebSocket-Protocol values like mqtt, wamp.2.json, soap, xmpp and stomp — with the purpose and defining specification of each.

How is a WebSocket subprotocol negotiated?

In the opening handshake the client sends a Sec-WebSocket-Protocol request header listing one or more subprotocol tokens it supports, in order of preference. The server picks at most one it also supports and echoes that single value in its Sec-WebSocket-Protocol response header. If the server omits the header, no subprotocol is in effect.

WebSocket subprotocols

A raw WebSocket connection just moves opaque frames; a subprotocol defines the application-level message format running over it — MQTT, STOMP, WAMP, GraphQL subscriptions and more. The client and server agree on one during the handshake using the Sec-WebSocket-Protocol header. This reference lists common IANA-registered subprotocol identifiers with their purpose.

How it works

The client lists the subprotocols it supports, most-preferred first; the server selects exactly one and echoes it back:

GET /chat HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Protocol: graphql-transport-ws, graphql-ws

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Protocol: graphql-transport-ws

The chosen token must be one the client offered, compared with exact casing. If the server returns no Sec-WebSocket-Protocol header, the connection runs with no application subprotocol. Names are coordinated in the IANA registry so independent implementations interoperate.

Tips and notes

  • List subprotocols in preference order; the server picks the first it supports.
  • Tokens are case-sensitive and opaque — use the exact registered string.
  • A server must never select a subprotocol the client did not offer.
  • For public protocols, register the name with IANA to avoid collisions.