Stopped infinite loop

This commit is contained in:
Pierre HUBERT 2022-08-30 14:19:30 +02:00
parent 11d7ccf7c9
commit 1eedfba81c

View File

@ -41,9 +41,15 @@ async fn relay_connection(ws_url: String, socket: TcpStream) {
loop { loop {
match tcp_read.read(&mut buff).await { match tcp_read.read(&mut buff).await {
Ok(s) => { Ok(s) => {
if s == 0 {
log::info!("Got empty read TCP buffer. Stopping...");
break;
}
if let Err(e) = ws_write.send(Message::Binary(Vec::from(&buff[0..s]))).await { if let Err(e) = ws_write.send(Message::Binary(Vec::from(&buff[0..s]))).await {
log::error!( log::error!(
"Failed to write to WS connection! {:?} Exiting TCP read -> WS write loop...",e); "Failed to write to WS connection! {:?} Exiting TCP read -> WS write loop...",e);
break;
} }
} }
Err(e) => { Err(e) => {