diff --git a/src/connection.rs b/src/connection.rs index f26c19a8..ebb9f583 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -145,8 +145,10 @@ impl Connection { /// This is not a graceful close - pending operations will fail immediately with /// [`ConnectionError::Closed`]`(`[`Close::Local`]`)`, and data on unfinished streams is not /// guaranteed to be delivered. - pub fn close(&self) { - self.inner.close(0u8.into(), b""); + pub fn close(&self, reason: Option) { + let reason = reason + .unwrap_or_else(|| "The connection was closed intentionally by qp2p.".to_string()); + self.inner.close(0u8.into(), &reason.into_bytes()); } async fn send_uni(&self, msg: Bytes, priority: i32) -> Result<(), SendError> {