Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/openshell-server/src/grpc/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use tokio::net::{TcpListener, TcpStream};
use tokio::sync::mpsc;
use tokio_stream::wrappers::ReceiverStream;
use tonic::{Request, Response, Status};
use tracing::{info, warn};
use tracing::{debug, info, warn};

use russh::ChannelMsg;
use russh::client::AuthResult;
Expand Down Expand Up @@ -1001,7 +1001,7 @@ async fn bridge_forward_tcp_stream(
}
Ok(None) => break,
Err(err) => {
warn!(sandbox_id = %sandbox_id_in, channel_id = %channel_id_in, error = %err, "ForwardTcp: inbound stream failed");
debug!(sandbox_id = %sandbox_id_in, channel_id = %channel_id_in, error = %err, "ForwardTcp: inbound stream ended");
break;
}
}
Expand Down
27 changes: 24 additions & 3 deletions crates/openshell-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ fn is_benign_tls_handshake_failure(error: &std::io::Error) -> bool {
)
}

fn is_benign_connection_close(error: &(dyn std::error::Error + 'static)) -> bool {
let msg = error.to_string();
msg.contains("connection closed")
|| msg.contains("connection reset")
|| msg.contains("connection error")
|| msg.contains("error reading a body from connection")
|| msg.contains("broken pipe")
}

impl ServerState {
/// Create new server state.
#[must_use]
Expand Down Expand Up @@ -475,7 +484,11 @@ fn spawn_gateway_connection(
) =>
{
if let Err(e) = service.serve_service_http(stream).await {
error!(error = %e, client = %addr, listen = %listen_addr, "Plaintext service HTTP connection error");
if is_benign_connection_close(e.as_ref()) {
debug!(error = %e, client = %addr, listen = %listen_addr, "Plaintext service HTTP connection closed");
} else {
error!(error = %e, client = %addr, listen = %listen_addr, "Plaintext service HTTP connection error");
}
}
}
Ok(ConnectionProtocol::PlainHttp) => {
Expand All @@ -485,7 +498,11 @@ fn spawn_gateway_connection(
match acceptor.inner().accept(stream).await {
Ok(tls_stream) => {
if let Err(e) = service.serve(tls_stream).await {
error!(error = %e, client = %addr, "Connection error");
if is_benign_connection_close(e.as_ref()) {
debug!(error = %e, client = %addr, "Connection closed");
} else {
error!(error = %e, client = %addr, "Connection error");
}
}
}
Err(e) => {
Expand All @@ -505,7 +522,11 @@ fn spawn_gateway_connection(
} else {
tokio::spawn(async move {
if let Err(e) = service.serve(stream).await {
error!(error = %e, client = %addr, "Connection error");
if is_benign_connection_close(e.as_ref()) {
debug!(error = %e, client = %addr, "Connection closed");
} else {
error!(error = %e, client = %addr, "Connection error");
}
}
});
}
Expand Down
Loading