• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


27 Mar, 2025

Updated at 18 May, 2025

How would you implement a WebTransport over HTTP/2 server using JavaScript/WebAssembly in the browser?

Originally asked over on superuser.

I'm scraping the surface of implementing WebTransport over HTTP/2 using Direct Sockets TCPServerSocket in an Isolated Web App (IWA) in the browser.

So far I have successfully created an HTTP and WebSocket server using TCPServerSocket, see https://github.com/guest271314/direct-sockets-http-ws-server/blob/main/assets/script.js.

The requirement shoukd be possible per one of the IWA maintainers

There's nothing stopping you from implementing your own TLS client/server library on top of the Direct Sockets API. The API proposed here makes that easier by allowing you to validate certificates using the browser's certificate store instead of providing your own.

From my reading of the WICG repository HTTPS is explicitly not allowed https://github.com/WICG/direct-sockets/issues/19.

That issue is obsolete. There is nothing stopping you from implementing a WebTransport server other than building an implementation using JavaScript or WebAssembly.

No, verifying certificates isn't necessary to implement an HTTP/2 server. You could do that today with TCPServerSocket, or implement a QUIC server with UDPSocket.

This presents some challenges.

  1. WebTransport uses the https URI.
  1. Protocol Overview

    WebTransport servers are identified by an HTTPS URI as defined in Section 4.2.2 of [HTTP].

The browser will throw an error when http: protocol is used with WebTransport() constructor.

This means I either have to try to intercept the http: request somehow, or implement https: in the browser. Creating self-signed certificates is not the issue.

  1. It's not clear to me, yet, how to create HTTP/2 frames. I've got some guidance from here https://github.com/molnarg/node-http2, which I have bundled to a standalone script, yet the code was created for general HTTP/2 connections, not WebTransport-specific, e.g.,

When an HTTP/2 connection is established, the server sends a SETTINGS_WEBTRANSPORT_MAX_SESSIONS setting with a value greater than "0" to indicate that it supports WebTransport over HTTP/2.

How would you implement a WebTransport over HTTP/2 server using JavaScript/WebAssembly in the browser?