Skip to content

Commit 57788a6

Browse files
authored
Improve error message on websocket client close (#392)
Currently the server side prints the error message every time the client sends the Close frame. Since the frame is sent on most connections, this leads to unneccary spam. I haven't tested the http2 variant, but from looking at the code, it follows the same pattern with a different ErrorKind. With the lower priority log level, this can be filtered easily. The distinct messages also help with checking the logs by hand.
1 parent ace8389 commit 57788a6

File tree

1 file changed

+6
-1
lines changed
  • src/tunnel/transport

1 file changed

+6
-1
lines changed

src/tunnel/transport/io.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::tunnel::transport::websocket::{WebsocketTunnelRead, WebsocketTunnelWr
33
use bytes::{BufMut, BytesMut};
44
use futures_util::{pin_mut, FutureExt};
55
use std::future::Future;
6+
use std::io::ErrorKind;
67
use std::pin::Pin;
78
use std::sync::Arc;
89
use std::time::Duration;
@@ -191,7 +192,11 @@ pub async fn propagate_remote_to_local(
191192
};
192193

193194
if let Err(err) = msg {
194-
error!("error while reading from tunnel rx {}", err);
195+
match err.kind() {
196+
ErrorKind::NotConnected => debug!("Connection closed frame received"),
197+
ErrorKind::BrokenPipe => debug!("Remote side closed connection"),
198+
_ => error!("error while reading from tunnel rx {err}"),
199+
}
195200
break;
196201
}
197202
}

0 commit comments

Comments
 (0)