Closed TimonPost closed 2 years ago
client unidirectional stream 0
The 0 here is a stream index. This is the human-readable decoding of a stream ID, which encodes the initiator, the directionality, and the index. See RFC 9000·§2.1.
Thanks! Now it makes sense. This is exactly what was wrong with my implementation.
I have some bug where I get a
Stream Readable
event fromquic-proto
but its stream id is 0 for unidirectional streams.The
Frame::Stream(frame)
event inprocess_payload
its stream id is0
. This triggers the eventStreamReadable
inStreamState::on_stream_frame
with stream id0
.Both on the server and on the client this stream id is 0. Whilst when I inspect the wireshark server capture the stream id is 2! As is expected for a uni stream.
Client
Server
I added a trace log to
process_payload
andStreamState::on_stream_frame
(which causes the readable stream event) to validate if this id is 0 there as well.Server
Client
But.... Looking at the Wireshark snapshot
The stream has the id of 2! Any idea what's going on here? So summarized: The payload has the correct stream id while the payload parsing code doesn't seem to get it right.
Minimal code that reproduces the bug
Click to expand!
## **Server** ```rust mod common; use common::{make_client_endpoint, make_server_endpoint}; use rustls::{Certificate, PrivateKey, RootCertStore}; use std::{fs, thread}; use rustls::internal::msgs::codec::Codec; use std::sync::Arc; use quinn::{ClientConfig, Endpoint, ServerConfig}; use rustls::client::{ServerCertVerified, ServerCertVerifier}; use std::time::Duration; use std::net::SocketAddr; pub fn generate_self_signed_cert() -> (Certificate, PrivateKey) { let certificate = rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap(); let serialized_key = certificate.serialize_private_key_der(); let serialized_certificate = certificate.serialize_der().unwrap(); fs::write(&"cert.der", &serialized_certificate).expect("failed to write certificate"); fs::write(&"key.der", &serialized_key).expect("failed to write private key"); (Certificate(serialized_certificate), PrivateKey(serialized_key)) } fn default_server_config() -> ServerConfig { let (cert, key) = generate_self_signed_cert(); let mut store = RootCertStore::empty(); store.add(&cert); let config = ServerConfig::with_single_cert(vec![cert], key) .unwrap(); config } #[tokio::main] async fn main() -> Result<(), Box