aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-protocol/src')
-rw-r--r--azalea-protocol/src/connect.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/azalea-protocol/src/connect.rs b/azalea-protocol/src/connect.rs
index c0c1a622..2400c712 100644
--- a/azalea-protocol/src/connect.rs
+++ b/azalea-protocol/src/connect.rs
@@ -11,6 +11,7 @@ use crate::write::write_packet;
use azalea_auth::sessionserver::SessionServerError;
use azalea_crypto::{Aes128CfbDec, Aes128CfbEnc};
use bytes::BytesMut;
+use log::info;
use std::fmt::Debug;
use std::marker::PhantomData;
use std::net::SocketAddr;
@@ -131,13 +132,22 @@ where
{
/// Write a packet to the server.
pub async fn write(&mut self, packet: W) -> std::io::Result<()> {
- write_packet(
+ if let Err(e) = write_packet(
&packet,
&mut self.write_stream,
self.compression_threshold,
&mut self.enc_cipher,
)
.await
+ {
+ // detect broken pipe
+ if e.kind() == std::io::ErrorKind::BrokenPipe {
+ info!("Broken pipe, shutting down connection.")
+ self.shutdown();
+ }
+ return Err(e);
+ }
+ Ok(())
}
/// End the connection.