tonhowtf/omniget · error

Relay error

Error message

Relay error: {}

What it means

The P2P relay protocol signals failures by sending a line prefixed with 'ERROR '. check_relay_error parses that prefix and converts the remainder into an anyhow error with this message. It surfaces server-side rejections of the client's protocol commands.

Solutions

  1. Read the relay's message embedded in the error to see the specific rejection
  2. Verify client and relay protocol versions match
  3. Re-register/join the relay room before sending data commands
  4. Check relay server logs for why the command was rejected

Example fix

// before
let resp = read_line(&mut reader).await?;
check_relay_error(&resp)?;
// after
let resp = read_line(&mut reader).await?;
if let Err(e) = check_relay_error(&resp) {
    tracing::warn!("relay rejected command, response={:?}", resp);
    return Err(e.context("relay rejected our request; verify code and protocol version"));
}
Defensive patterns

Strategy: try-catch

Validate before calling

// before each command, ensure the relay session is registered
anyhow::ensure!(joined_room.load(Ordering::SeqCst), "not joined to relay room");

Try / catch

let resp = read_line(&mut reader).await?;
if let Err(e) = check_relay_error(&resp) {
    error!("relay said: {} — response: {:?}", e, resp);
    return Err(e);
}

Prevention

When it happens

Trigger: Any relay response line beginning with "ERROR " — e.g. the relay rejected a JOIN/registration, room is full, peer not found, or the requested code is unknown.

Common situations: Connecting to a relay with a different protocol version; using a share code whose room no longer exists on the relay; relay rejecting unauthenticated peers; sending commands out of order.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/92e06f895207c307. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/src/platforms/p2p/mod.rs:49

    .map_err(|_| anyhow!("Connection to relay timed out (10s)"))?
    .map_err(|e| anyhow!("Failed to connect to relay {}: {}", addr, e))?;
    Ok(stream)
}

async fn read_line(
    reader: &mut BufReader<tokio::io::ReadHalf<TcpStream>>,
) -> anyhow::Result<String> {
    let mut line = String::new();
    let n = reader.read_line(&mut line).await?;
    if n == 0 {
        anyhow::bail!("Relay closed connection unexpectedly");
    }
    Ok(line.trim_end().to_string())
}

fn check_relay_error(line: &str) -> anyhow::Result<()> {
    if let Some(err) = line.strip_prefix("ERROR ") {
        anyhow::bail!("Relay error: {}", err);
    }
    Ok(())
}

pub struct P2pDownloader;

impl P2pDownloader {
    pub fn new() -> Self {
        Self
    }
}

#[async_trait]
impl PlatformDownloader for P2pDownloader {
    fn name(&self) -> &str {
        "p2p"
    }

View on GitHub (pinned to 8600b91f42)