WebTransport.Client 0.1.3

Suggested Alternatives

Demiurgos.WebTransport.Client

Additional Details

Migrated to a new package ID

There is a newer version of this package available.
See the version list below for details.
dotnet add package WebTransport.Client --version 0.1.3
                    
NuGet\Install-Package WebTransport.Client -Version 0.1.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WebTransport.Client" Version="0.1.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WebTransport.Client" Version="0.1.3" />
                    
Directory.Packages.props
<PackageReference Include="WebTransport.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WebTransport.Client --version 0.1.3
                    
#r "nuget: WebTransport.Client, 0.1.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package WebTransport.Client@0.1.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WebTransport.Client&version=0.1.3
                    
Install as a Cake Addin
#tool nuget:?package=WebTransport.Client&version=0.1.3
                    
Install as a Cake Tool

WebTransport C# Client

WebTransport.Client is a general-purpose C# WebTransport client package targeting .NET Standard 2.1.

The package is designed to be usable from ordinary C# projects and Unity without exposing Unity-specific APIs.

Current Status

This repository contains the initial package architecture:

  • managed WebTransport.Client API for sessions, streams, and datagrams
  • managed WebTransport.Native P/Invoke wrapper
  • stable native C ABI in native/webtransport_native
  • MsQuic connection module with conditional build support
  • HTTP/3 SETTINGS and WebTransport extended CONNECT scaffolding
  • managed unit tests and opt-in interop tests

The native library uses MsQuic for QUIC/TLS transport. It can start a real connection with HTTP/3 ALPN (h3), send HTTP/3 client SETTINGS, send a minimally QPACK-encoded WebTransport extended CONNECT request, parse a simple response :status, open bidirectional WebTransport streams, route stream writes through MsQuic, and send/receive WebTransport datagrams through MsQuic datagrams. Managed ConnectAsync completes after the WebTransport session is accepted, and client-initiated stream/datagram receive APIs await native data events instead of requiring caller polling. Full peer SETTINGS parsing from live control streams, robust QPACK, and peer-initiated stream accept are still in progress.

Usage Shape

await using var client = new WebTransportClient();
await using WebTransportSession session = await client.ConnectAsync(
    new Uri("https://example.com/transport"));

await using WebTransportStream stream = await session.OpenBidirectionalStreamAsync();
await stream.WriteAsync(new byte[] { 1, 2, 3 });

await session.SendDatagramAsync(new byte[] { 4, 5, 6 });
WebTransportDatagram datagram = await session.ReceiveDatagramAsync();

ConnectAsync returns only after the remote endpoint accepts the WebTransport extended CONNECT request.

Packages

  • WebTransport.Client: public API for C# consumers.
  • WebTransport.Native: native loader and ABI wrapper.
  • io.demiurgos.webtransport: Unity Package Manager package assembled from the same managed and native release artifacts.

Native runtime assets are expected under NuGet's standard layout:

runtimes/win-x64/native/webtransport_native.dll
runtimes/linux-x64/native/libwebtransport_native.so
runtimes/osx-arm64/native/libwebtransport_native.dylib
runtimes/android-arm64/native/libwebtransport_native.so
runtimes/ios/native/libwebtransport_native.a

Unity

Unity users should consume the same .NET Standard 2.1 managed assemblies as other C# users. The UPM package template lives under upm/io.demiurgos.webtransport, and generated release packages are written to artifacts/upm/io.demiurgos.webtransport.

WebGL is not supported by the native backend. A browser JavaScript backend would be a separate package.

Build

Managed build and tests:

dotnet test WebTransport.sln

The native backend requires MsQuic. Configure VCPKG_ROOT before building native presets.

Contributor Native Dependencies

This repo uses vcpkg manifest mode for native dependencies. Install vcpkg once somewhere under your user or developer tools directory:

mkdir $env:USERPROFILE\dev
git clone https://github.com/microsoft/vcpkg.git $env:USERPROFILE\dev\vcpkg
& "$env:USERPROFILE\dev\vcpkg\bootstrap-vcpkg.bat"
[Environment]::SetEnvironmentVariable("VCPKG_ROOT", "$env:USERPROFILE\dev\vcpkg", "User")
$env:VCPKG_ROOT = "$env:USERPROFILE\dev\vcpkg"

Then build the native library with MsQuic:

.\scripts\build-native.ps1 -Preset windows-msquic

The windows-msquic preset uses vcpkg.json to restore msquic. Release packages should use windows-msquic-release, which keeps MsQuic enabled and disables native test hooks.

With the MsQuic presets, Windows native outputs are written under:

artifacts/native-build-msquic/native/webtransport_native/Release/
artifacts/native-build-msquic-release/native/webtransport_native/Release/

Stage native runtime assets, pack NuGet packages, and assemble the UPM package:

.\scripts\Build-Packages.ps1 -Configuration Release -NativePreset windows-msquic-release -Rid win-x64

For local script validation without rebuilding native code:

.\scripts\Build-Packages.ps1 -Configuration Release -SkipNativeBuild -SkipTests -AllowMissingNativeAssets

NuGet packages are written to artifacts/nuget. The generated UPM package is written to artifacts/upm/io.demiurgos.webtransport.

For local NuGet publish from Windows, copy scripts/build-nuget-release.bat.example and scripts/push-nuget.bat.example to scripts/build-nuget-release.bat and scripts/push-nuget.bat, set your API key in push-nuget.bat, then run those scripts (they are gitignored).

For local interop tests, copy the built native library next to the test assembly:

Copy-Item artifacts/native-build-msquic/native/webtransport_native/Release/webtransport_native.dll `
  tests/WebTransport.Interop.Tests/bin/Debug/net8.0/ -Force

vcpkg manifest installs are local to the CMake build tree by default, under artifacts/native-build-msquic/vcpkg_installed. If vcpkg produces an additional runtime DLL for your triplet, copy that DLL next to webtransport_native.dll as well.

Run the opt-in MsQuic connection test:

$env:WEBTRANSPORT_MSQUIC_TEST_URL = "https://example.com/transport"
$env:WEBTRANSPORT_ALLOW_UNTRUSTED_CERTS = "1"
dotnet test WebTransport.sln

The opt-in test expects a native build linked with MsQuic and reports either a connection event or a meaningful transport/TLS failure. It does not yet establish a complete WebTransport session.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.