kixelated / web-transport-rs

Rust WebTransport library for native and WASM
https://quic.video
Apache License 2.0
100 stars 14 forks source link

Datagram support #6

Closed kixelated closed 11 months ago

kixelated commented 1 year ago

Pls somebody implement it. It should be super simple, but I don't have a use-case for them yet. Hit me up if you're interested and need pointers.

kelvinkirima014 commented 1 year ago

Hello @kixelated. I'd love to implement datagrams for this crate. Do you have any contribution guidelines I should follow? Also, I'd very much appreciate the pointers.

kixelated commented 1 year ago

Hello @kixelated. I'd love to implement datagrams for this crate. Do you have any contribution guidelines I should follow? Also, I'd very much appreciate the pointers.

Absolutely! There's no contribution guidelines; just open a PR.

You'll have read the specs and test it against Chrome. Here's the WebTransport specification and you'll have to follow the breadcrumbs: https://www.ietf.org/archive/id/draft-ietf-webtrans-http3-08.html#section-4.4

I thiiink it's just the session ID in front of each datagram but there's probably another VarInt in there too. Note that Quinn already has datagrams; you just need to figure out the required prefix.

kelvinkirima014 commented 1 year ago

Alright, I'll start working on it and update you here on the progress.

kelvinkirima014 commented 1 year ago

Hello @kixelated. I think I have the datagram implementation working, but I can't get a webtransport connection through on the browser due to TLS certs exchange. I run into this error even though both my server and client certs point to the same file. Have any idea why this maybe happening?

Initiating connection...
Failed to establish a connection to https://127.0.0.1:4443/: net::ERR_QUIC_PROTOCOL_ERROR.QUIC_TLS_CERTIFICATE_UNKNOWN (TLS handshake failure (ENCRYPTION_HANDSHAKE) 46: certificate unknown).

I have tested with a Rust client and the datagram transfer works as expected.

Datagram screenshot

kixelated commented 1 year ago

Yeah, welcome to QUIC. You need a valid TLS cert which is crazy annoying for development.

The easiest workaround is in chrome://flags. Search for WebTransport and you'll find a way to allow insecure certs for localhost.

Otherwise you'll need to use the certificateHash parameter when establishing the connection from JS. It accepts a certificate by sha256 hash, provided the certificate is valid for <14 days. That's what moq-rs and moq-js use for local development but it's more annoying to set up as you need to exchange that hash somehow (ex. HTTPS).

kixelated commented 1 year ago

I can also make an dev setup if it would be helpful. Something like this but configured for local development

kelvinkirima014 commented 1 year ago

It's this flag, right?


WebTransport Developer Mode
When enabled, removes the requirement that all certificates used for WebTransport over HTTP/3 are issued by a known certificate root. – Mac, Windows, Linux, ChromeOS, Android, Fuchsia, Lacros

I have it enabled and I still get the error.

kelvinkirima014 commented 1 year ago

Yes, I think the dev setup would be very helpful!

kixelated commented 1 year ago

Weird that you still get an error.

Give me a few days and I'll set up a quick dev page. Thanks again for implementing this.

kelvinkirima014 commented 1 year ago

Great, meanwhile maybe you can review the code at:

https://github.com/kelvinkirima014/webtransport-rs

kelvinkirima014 commented 1 year ago

Hello @kixelated, I managed to test out the datagram implementation on Chrome by using some scripts I found on moq-rs. The good news? I was able to succesfully send some datagram from Js client code over to my server and print them out!

Screenshot from 2023-11-20 21-03-54

I'll go ahead and make a PR!

kixelated commented 1 year ago

Fantastic.

I've been super sick the last few days and haven't been able to set up the dev environment. Thanks for figuring it out.

kelvinkirima014 commented 1 year ago

I'm sorry to hear you are unwell, I wish you a quick recovery! You are very welcome, this was a joy to work on!