24

The upcoming HTTP/3 standard is no longer based on TCP, but on the QUIC protocol. WebSocket is based on TCP and is initiated as HTTP update.

Is a WebSocket connection initiated as HTTP/3 update based on QUIC instead of TCP? Or is it not possible to update a HTTP/3 connection to a WebSocket connection?

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222
Benjamin Buch
  • 4,752
  • 7
  • 28
  • 51
  • 1
    The current WebSocket protocol requires TCP, though there is nothing stopping *implementations* from including support for QUIC at the transport layer. There are proposals to adapt the WebSocket protocol to QUIC/HTTP3, though. – Remy Lebeau Aug 06 '19 at 18:36
  • 5
    I think a new approach is taking over: a replacement for WebSockets and WebRTC that supports both Reliable streams and Unreliable datagrams optionally via quic: https://wicg.github.io/web-transport/ For now I think you're best off using SSE (EventSource) for QUIC based server sent events – Thomas Grainger Jun 28 '20 at 16:24

2 Answers2

14

UPDATE: 2023: as of the writing of this post there is a relatively new specification RFC9220 for websockets built on top of HTTP3 https://datatracker.ietf.org/doc/rfc9220/ .

  • Please note RFC 9220 is a specification and so does not help answer questions like: does web-browser X/Y/Z (or library A/B/C, or operating system D/E/F) support this?

Since this is the top search result for "http3 websockets", I want to keep the answers up-to-date.

As of December 2021, there is now an IETF draft that amends RFC8441 (Bootstrapping WebSockets with HTTP/2) with the adjustments necessary for HTTP/3. If the draft is accepted, there will be a standardized way for WebSockets to be initiated over HTTP/3.

The draft is on its second revision and will expire in July 2022 if there are no further revisions and it is not accepted by that time.

Trevor Boyd Smith
  • 18,164
  • 32
  • 127
  • 177
David L Kinney
  • 156
  • 1
  • 2
9

Currently only HTTP/1.1 is supported by the RFC6455 to be used for connection upgrade.

Once a connection to the server has been established (including a
connection via a proxy or over a TLS-encrypted tunnel), the client
MUST send an opening handshake to the server. The handshake consists of an HTTP Upgrade request, along with a list of required and
optional header fields. The requirements for this handshake are as
follows.

  1. The handshake MUST be a valid HTTP request as specified by [RFC2616].

  2. The method of the request MUST be GET, and the HTTP version MUST be at least 1.1.

However, there are proposals to support HTTP/2 as well as HTTP/3 (as Remy Lebeau mentioned in comment above).

Community
  • 1
  • 1
Sergey Kamardin
  • 1,640
  • 1
  • 18
  • 22
  • 5
    For HTTP/2 this answer is slightly outdated, see: https://tools.ietf.org/html/rfc8441 – Sam Whited Jan 21 '21 at 15:01
  • I don't get this answer. Point 2 clearly states "at least 1.1". There's no reason for Websockets not to work over Http3. – freakish Aug 29 '22 at 06:17