Pumpkin-MC/Pumpkin · error · PacketError

Failed to send packet

Error message

Failed to send packet: {0}

What it means

PacketError variant wrapping an io::Error raised when the RCON connection's write of a packet fails. It fires at the send site (socket write during write_buf/flush), meaning the TCP connection to the RCON client was broken or reset mid-send — the embedded error carries the OS-level cause.

Solutions

  1. Terminate that RCON client session
  2. Check socket state before writing responses
  3. Log the io error at debug level
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/pumpkin-protocol/src/rcon.rs:54 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09). Data as JSON: /api/errors/9c2aceb1e367347e. Report an issue: GitHub.

Appendix: source

Thrown at crates/pumpkin-protocol/src/rcon.rs:54

    pub fn write_buf(self, id: i32, body: &str) -> BytesMut {
        let mut buf = BytesMut::new();
        // 10 is for 4 bytes ty, 4 bytes id, and 2 terminating nul bytes.
        buf.put_i32_le(10 + body.len() as i32);
        buf.put_i32_le(id);
        buf.put_i32_le(self as i32);
        let bytes = body.as_bytes();
        buf.put_slice(bytes);
        buf.put_u8(0);
        buf.put_u8(0);
        buf
    }
}

#[derive(Error, Debug)]
pub enum PacketError {
    #[error("Invalid length")]
    InvalidLength,
    #[error("Failed to send packet: {0}")]
    FailedSend(std::io::Error),
    #[error("Missing packet null terminator")]
    MissingNullTerminator,
    #[error("Invalid packet string body: {0}")]
    InvalidBody(std::str::Utf8Error),
    #[error("Unknown packet type: {0}")]
    UnknownPacketType(i32),
}

#[derive(Debug, PartialEq, Eq)]
/// Serverbound packet
pub struct Packet {
    id: i32,
    ptype: ServerboundPacket,
    body: Box<str>,
}

impl Packet {

View on GitHub (pinned to 8d4639e25a)