[feat] client robust against server disconnects and better logging on the client

This commit is contained in:
2024-11-10 15:45:55 +01:00
parent 89af1f9176
commit 9f8c6d3417
4 changed files with 95 additions and 84 deletions

View File

@ -66,14 +66,12 @@ impl Server {
tracing::info!("{} connected", conn_ctx.remote_addr);
while let Ok(Some(stream)) = connection.accept_bidirectional_stream().await {
tracing::debug!("{} stream opened: {:?}", conn_ctx.remote_addr, stream);
let (mut rx, mut tx) = stream.split();
let conn_ctx = conn_ctx.clone();
// spawn a new task for the stream
tokio::spawn(async move {
tracing::debug!("{} stream opened", conn_ctx.remote_addr);
tracing::trace!("{} stream opened", conn_ctx.remote_addr);
// handle streams
while let Ok(Some(data)) = rx.receive().await {