Local webtransport in firefox

TL;DR Webtransport does work in chromium but not in firefox.


I started a kubo node locally, it exposes these multiaddresses:

/ip4/127.0.0.1/tcp/4001/p2p/12D3KooWF44SaSomGuUSNycgpkRwQcxcsMYeNbtn6XCHPR2ojodv
/ip4/127.0.0.1/udp/4001/quic-v1/p2p/12D3KooWF44SaSomGuUSNycgpkRwQcxcsMYeNbtn6XCHPR2ojodv
/ip4/127.0.0.1/udp/4001/quic-v1/webtransport/certhash/uEiCQEENr7FShHOkuCAUCgW-oahGIGj0Mk3tOHXQjrsWGWQ/certhash/uEiCG3LMdW9dtRC_kXft2TlE66kZ4RX1MzQksLwxRgbJMVw/p2p/12D3KooWF44SaSomGuUSNycgpkRwQcxcsMYeNbtn6XCHPR2ojodv

Then I initialize a webtransport libp2p connection (in Helia):

const local_peer = [
  '/ip4/127.0.0.1/tcp/4001/p2p/12D3KooWF44SaSomGuUSNycgpkRwQcxcsMYeNbtn6XCHPR2ojodv',
  '/ip4/127.0.0.1/udp/4001/quic-v1/p2p/12D3KooWF44SaSomGuUSNycgpkRwQcxcsMYeNbtn6XCHPR2ojodv',
  '/ip4/127.0.0.1/udp/4001/quic-v1/webtransport/certhash/uEiCQEENr7FShHOkuCAUCgW-oahGIGj0Mk3tOHXQjrsWGWQ/certhash/uEiCG3LMdW9dtRC_kXft2TlE66kZ4RX1MzQksLwxRgbJMVw/p2p/12D3KooWF44SaSomGuUSNycgpkRwQcxcsMYeNbtn6XCHPR2ojodv'
]

const libp2p = await createLibp2p({
  peerDiscovery: [
    bootstrap({
      list: local_peer
    })
  ],
  transports: [webTransport()],
  connectionGater: {
    denyDialMultiaddr: async () => false
  }
})

This works well in chromium, I see this connection in the network tab

https://127.0.0.1:4001/.well-known/libp2p-webtransport?type=noise	

But this does not work in firefox, I get this error:

// WebTransport connection rejected
WebTransportError { source: "session", streamErrorCode: null, name: "WebTransportError", message: "WebTransport connection rejected", code: 0, result: 0, filename: "", lineNumber: 0, columnNumber: 0, data: null }

Does anybody know where the problem comes from? I’m aware webtransport is only available in a “secure context” (see doc WebTransport - Web APIs | MDN) but it seems the certificate is accepted by chromium and not by firefox.

If you look at the MDN docs options.serverCertificateHashes is not yet supported in Firefox (although IIUC it’s in beta! 1873263 - Webtransport: serverCertificateHashes does not work as expected). This is required for talking to a kubo node since without it you’d need to have a CA signed certificate.

So if this indeed made it into Firefox 125 you should only have to wait a few weeks until it’s released Firefox 125 for developers - Mozilla | MDN. Otherwise you should be able to download the Firefox beta and try it out.

Initial testing shows that WebTransport should work much better in Firefox than Chromium at the moment due to an ongoing issue with Chromium in need of resolution Chromium (feel free to star the issue so they know people care).

1 Like