diff --git a/foundations/src/http/server/stream/quic.rs b/foundations/src/http/server/stream/quic.rs index fd9b21e03..b7fb79fef 100644 --- a/foundations/src/http/server/stream/quic.rs +++ b/foundations/src/http/server/stream/quic.rs @@ -8,6 +8,7 @@ use axum::response::IntoResponse; use bytes::{Buf, Bytes}; use futures::future::poll_fn; use futures::Future; +use h3::error::{Code, ErrorLevel}; use h3::ext::Protocol; use h3::server::{Builder, RequestStream}; use h3_quinn::{BidiStream, RecvStream, SendStream}; @@ -90,6 +91,14 @@ impl Backend for QuicBackend { break; }; + if !connection.remote_address_validated() { + if let Err(err) = connection.retry() { + tracing::debug!(error = %err, "failed to retry quic connection"); + } + + continue; + } + let connection = match connection.accept() { Ok(connection) => connection, Err(e) => { @@ -207,10 +216,23 @@ impl Connection { }, // An error occurred. Err(err) => { - tracing::debug!(err = %err, "error accepting request"); - self.service.on_error(err.into()).await; - connection_handle.cancel(); - break; + match err.get_error_level() { + ErrorLevel::ConnectionError => { + tracing::debug!(err = %err, "error accepting request"); + self.service.on_error(err.into()).await; + connection_handle.cancel(); + break; + } + ErrorLevel::StreamError => { + if let Some(Code::H3_NO_ERROR) = err.try_get_code() { + tracing::trace!("stream closed"); + } else { + tracing::debug!(err = %err, "stream error"); + self.service.on_error(err.into()).await; + } + continue; + } + } } } },