protocol property

Returns the protocol that the server has selected.

This property is read-only.


sProtocol = object.protocol


Property values

Type: DOMString

Protocol name that was accepted by the server.


Protocol negotiation is part of the WebSocket connection handshake. The protocol value is not set until the connection is established. If the client specifies one or more protocols, the server returns one or none of the protocols during the protocol negotiation in the handshake. After the connection is established, then the protocol value is either empty or set to the protocol that was accepted.

See also

WebSockets in Windows
WebSockets RFC 6455
The WebSocket API