tonhowtf/omniget · error
Relay error
Error message
Relay error: {} What it means
p2p.rs raises this in check_relay_error() when a line received from the relay starts with 'ERROR '. The relay-reported error text is extracted and wrapped as 'Relay error: {}'. This is the relay's way of signalling protocol/application failures (e.g. unknown code, no peer paired) back to the client.
Solutions
- Read the relay's message after the 'ERROR ' prefix — it states the exact relay-side cause.
- Verify the share code is correct and still active on the relay (see also 'Invalid share code').
- Ensure the sender is connected and registered with the relay before the receiver joins.
- Match relay and client protocol versions; update the client if the relay was upgraded.
- If the relay is overloaded or misconfigured, restart it or check its configuration/logs.
Example fix
// before
let line = read_line(&mut reader).await?;
check_relay_error(&line)?;
// after
let line = read_line(&mut reader).await?;
if let Err(e) = check_relay_error(&line) {
let relay_msg = e.to_string().trim_start_matches("Relay error: ").to_string();
if relay_msg.contains("unknown code") {
return Err(anyhow!("Share code not found on relay: {}", relay_msg));
}
return Err(e);
} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check the response shape yourself
if let Some(err) = line.strip_prefix("ERROR ") {
eprintln!("relay rejected: {err}");
} Type guard
// Rust
fn is_relay_error(line: &str) -> Option<&str> {
line.strip_prefix("ERROR ")
} Try / catch
let line = read_line(&mut reader).await?;
check_relay_error(&line).map_err(|e| {
anyhow!("relay refused operation: {}. verify the share code and sender status", e)
})?; Prevention
- Validate the share code before contacting the relay
- Ensure the sender has registered with the relay before the receiver connects
- Keep client and relay protocol versions in sync
- Log raw relay lines to diagnose protocol mismatches
When it happens
Trigger: Any relay response line with the 'ERROR ' prefix passed to check_relay_error() — called after read_line in download and run_sender. Examples: 'ERROR unknown code', 'ERROR peer not connected', relay-side rate limits or protocol violations.
Common situations: Typo'd or expired share code rejected by relay; connecting as receiver before the sender has registered; relay configured with different protocol version; relay under load rejecting new sessions.
Related errors
- Relay error
- Relay closed connection unexpectedly
- Unexpected relay response
- Relay closed connection unexpectedly
- Unexpected relay response
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/f9e7ad17797ab204.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/platforms/p2p.rs:47
.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)