WebTransport
WebTransport is a network transport protocol based on HTTP/3, providing bidirectional communication capabilities between clients and servers while ensuring low latency, high throughput, and security.
Use Cases
WebTransport is particularly suitable for the following scenarios:
- Real-time Applications: Online gaming, real-time collaboration tools, video conferencing, and other applications requiring low-latency communication.
- Large File Transfers: Supports high-throughput data transmission, ideal for media streaming and large file uploads/downloads.
- Multiplexed Communication: Allows simultaneous establishment of multiple bidirectional and unidirectional data streams.
- Datagram Communication: Supports datagram communication without guaranteed order or reliability, suitable for scenarios with extremely high real-time requirements.
Compared to WebSocket, WebTransport offers lower latency and more flexible communication patterns, especially performing better in unstable network environments.
Salvo Implementation
The Salvo framework provides built-in support for WebTransport, allowing developers to easily build WebTransport-based applications. Key features include:
- Support for establishing WebTransport sessions
- Support for bidirectional stream communication
- Support for unidirectional stream communication
- Support for datagram transmission
- Server-initiated communication streams
Simple Example
Below is a simplified example of implementing a WebTransport server using Salvo:
Configuration and Startup
Starting a Salvo application with WebTransport support requires configuring TLS certificates and a QUIC listener:
Complete Example
To learn more about using WebTransport in Salvo, check out the complete example on GitHub: https://github.com/salvo-rs/salvo/blob/main/examples/webtransport
This example includes complete implementations for both server and client, demonstrating how to handle various types of WebTransport communication.