This test script can be run by placing it into quinn/examples/:
Script
```rs
use anyhow::Error;
use quinn::*;
use std::{net::ToSocketAddrs as _, sync::Arc};
use tracing::*;
use tracing_subscriber::prelude::*;
#[tokio::main]
async fn main() {
let t0 = std::time::Instant::now();
// init logging
let log_fmt = tracing_subscriber::fmt::format()
.compact()
.with_timer(tracing_subscriber::fmt::time::uptime())
.with_line_number(true);
let stdout_log = tracing_subscriber::fmt::layer()
.event_format(log_fmt);
let log_filter = tracing_subscriber::EnvFilter::new(
std::env::var(tracing_subscriber::EnvFilter::DEFAULT_ENV).unwrap_or("info".into()),
);
let log_subscriber = tracing_subscriber::Registry::default()
.with(log_filter)
.with(stdout_log);
tracing::subscriber::set_global_default(log_subscriber).expect("unable to install logger");
// generate keys (new version of Rustls)
let rcgen_cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap();
let key = rustls::pki_types::PrivatePkcs8KeyDer::from(rcgen_cert.key_pair.serialize_der());
let cert = rustls::pki_types::CertificateDer::from(rcgen_cert.cert);
let mut roots = rustls::RootCertStore::empty();
roots.add(cert.clone()).unwrap();
let certs = vec![cert];
let mut tasks = tokio::task::JoinSet::new();
// start server
fn spawn_server(
certs: &Vec>,
key: &rustls::pki_types::PrivatePkcs8KeyDer,
) -> (tokio::sync::oneshot::Sender<()>, impl std::future::Future
Running with localhost simulated latency set to 100 ms, I get this:
0.002362018s INFO server: mytest:72: constructing server endpoint
0.002986974s INFO client: mytest:157: client iteration i=0
0.003351156s INFO client: mytest:188: not attempting 0-rtt request
0.211132740s INFO client: mytest:128: beginning write_all and finish calls msg=1-rtt hello world (0-rtt not attempted)
0.211252627s INFO client: mytest:131: returned write_all and finish calls, beginning stopped call msg=1-rtt hello world (0-rtt not attempted)
0.313526152s INFO server:server_conn:server_stream: mytest:109: received message msg=1-rtt hello world (0-rtt not attempted)
0.415197619s INFO client: mytest:134: returned stopped call msg=1-rtt hello world (0-rtt not attempted)
1.893786818s INFO client:server: mytest:72: constructing server endpoint
3.000951223s INFO client: mytest:157: client iteration i=1
3.002888132s INFO client: mytest:165: attempting 0-rtt request
3.002975427s INFO client: mytest:128: beginning write_all and finish calls msg=0-rtt hello world
3.003032792s INFO client: mytest:131: returned write_all and finish calls, beginning stopped call msg=0-rtt hello world
3.210476403s INFO mytest:169: zero_rtt_accepted future resolved outcome=false
14.022478912s ERROR client: mytest:220: 0-RTT rejected
One round trip after the 0-RTT connection attempt was made, the ZeroRttAccepted resolves to false. However, it takes over 10 seconds more before the 0-RTT stream.stopped().await line resolves with an error.
This test script can be run by placing it into
quinn/examples/
:Script
```rs use anyhow::Error; use quinn::*; use std::{net::ToSocketAddrs as _, sync::Arc}; use tracing::*; use tracing_subscriber::prelude::*; #[tokio::main] async fn main() { let t0 = std::time::Instant::now(); // init logging let log_fmt = tracing_subscriber::fmt::format() .compact() .with_timer(tracing_subscriber::fmt::time::uptime()) .with_line_number(true); let stdout_log = tracing_subscriber::fmt::layer() .event_format(log_fmt); let log_filter = tracing_subscriber::EnvFilter::new( std::env::var(tracing_subscriber::EnvFilter::DEFAULT_ENV).unwrap_or("info".into()), ); let log_subscriber = tracing_subscriber::Registry::default() .with(log_filter) .with(stdout_log); tracing::subscriber::set_global_default(log_subscriber).expect("unable to install logger"); // generate keys (new version of Rustls) let rcgen_cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap(); let key = rustls::pki_types::PrivatePkcs8KeyDer::from(rcgen_cert.key_pair.serialize_der()); let cert = rustls::pki_types::CertificateDer::from(rcgen_cert.cert); let mut roots = rustls::RootCertStore::empty(); roots.add(cert.clone()).unwrap(); let certs = vec![cert]; let mut tasks = tokio::task::JoinSet::new(); // start server fn spawn_server( certs: &VecRunning with localhost simulated latency set to 100 ms, I get this:
One round trip after the 0-RTT connection attempt was made, the
ZeroRttAccepted
resolves to false. However, it takes over 10 seconds more before the 0-RTTstream.stopped().await
line resolves with an error.