{"record":{"id":"9b35a24da40720e4","repo":"spacedriveapp/spacedrive","slug":"failed-to-connect-to-device","errorCode":null,"errorMessage":"Failed to connect to device: {}","messagePattern":"Failed to connect to device: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"core/src/ops/files/copy/strategy.rs","lineNumber":498,"sourceCode":"\t\t\t\t)\n\t\t\t})?;\n\t\tdrop(registry);\n\n\t\tlet endpoint = networking_guard\n\t\t\t.endpoint()\n\t\t\t.ok_or_else(|| anyhow::anyhow!(\"Networking endpoint not available\"))?;\n\n\t\tctx.log(format!(\n\t\t\t\"Opening PULL connection to node {} (device {})\",\n\t\t\tnode_id, source_device_id\n\t\t));\n\n\t\t// Connect to remote device\n\t\tlet node_addr = iroh::EndpointAddr::new(node_id);\n\t\tlet connection = endpoint\n\t\t\t.connect(node_addr, b\"spacedrive/filetransfer/1\")\n\t\t\t.await\n\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to connect to device: {}\", e))?;\n\n\t\tlet (mut send_stream, mut recv_stream) = connection\n\t\t\t.open_bi()\n\t\t\t.await\n\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to open bidirectional stream: {}\", e))?;\n\n\t\t// Send PullRequest\n\t\tlet transfer_id = uuid::Uuid::new_v4();\n\t\tlet current_device_id = crate::device::get_current_device_id();\n\t\t// Normalize path separators to forward slashes for cross-platform transmission.\n\t\t// The receiving device may use a different OS separator (Windows \\ vs Unix /).\n\t\tlet normalized_source_path =\n\t\t\tPathBuf::from(source_path.to_string_lossy().replace('\\\\', \"/\"));\n\t\tlet pull_request =\n\t\t\tcrate::service::network::protocol::file_transfer::FileTransferMessage::PullRequest {\n\t\t\t\ttransfer_id,\n\t\t\t\tsource_path: normalized_source_path,\n\t\t\t\trequested_by: current_device_id,","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/core/src/ops/files/copy/strategy.rs#L480-L516","documentation":"execute_pull connects to the peer's iroh node with ALPN b\"spacedrive/filetransfer/1\" (strategy.rs:494-498). The connect fails when the node is unreachable (offline, NAT without relay, relay outage), when the peer refuses the ALPN due to an incompatible daemon version, or on timeout. The underlying iroh error string is appended for diagnosis.","triggerScenarios":"Peer went offline between the registry lookup and the connect attempt; firewall/NAT blocks both direct and relayed paths; ALPN refused because the peer runs an older/newer protocol version; relay infrastructure unreachable.","commonSituations":"Remote device asleep or powered off; cross-network transfers during relay downtime; mixed daemon versions during a rolling upgrade.","solutions":["Confirm the peer device is online and retry the copy","Inspect the appended iroh error (timeout vs refused vs no route) to target the fix","Check relay configuration and firewall rules on both endpoints","Ensure both devices run daemon versions agreeing on the spacedrive/filetransfer/1 protocol"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"let online = networking.device_registry().read().await.get_node_by_device(device_id).is_some();\nif !online {\n    return Err(anyhow::anyhow!(\"peer {} not connected; connect() would fail\", device_id));\n}","typeGuard":null,"tryCatchPattern":"let mut last = None;\nfor attempt in 0..3 {\n    match endpoint.connect(iroh::EndpointAddr::new(node_id), alpn).await {\n        Ok(c) => return Ok(c),\n        Err(e) => { last = Some(e); tokio::time::sleep(Duration::from_secs(1 << attempt)).await; }\n    }\n}\nErr(anyhow::anyhow!(\"connect failed after retries: {:?}\", last))","preventionTips":["Confirm peer online status before initiating a PULL","Retry connections with exponential backoff; many failures are transient","Keep daemon versions aligned so the spacedrive/filetransfer/1 ALPN is always accepted"],"tags":["rust","spacedrive","pull","iroh","connection","network","cross-device"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}