{"record":{"id":"161ab77c4dcab265","repo":"influxdata/influxdb","slug":"io-error-0","errorCode":null,"errorMessage":"io error: {0}","messagePattern":"io error: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"influxdb3_client/src/lib.rs","lineNumber":75,"sourceCode":"    ApiError {\n        code: StatusCode,\n        message: String,\n        /// Machine-readable error code from JSON error responses, if present.\n        error_code: Option<String>,\n    },\n\n    #[error(\"failed to send {method} {url} request: {}\", reqwest_description(.source))]\n    RequestSend {\n        method: Method,\n        url: String,\n        #[source]\n        source: reqwest::Error,\n    },\n\n    #[error(\"failed to build an http client: {}\", reqwest_description(.0))]\n    Builder(#[source] reqwest::Error),\n\n    #[error(\"io error: {0}\")]\n    IO(#[from] std::io::Error),\n}\n\n/// Try to parse a JSON error response body with `error_code` and `message` fields.\n/// Returns `(message, error_code)`. If JSON parsing fails, treats the body as plain text.\npub(crate) fn parse_error_body(body: &str) -> (String, Option<String>) {\n    #[derive(serde::Deserialize)]\n    struct JsonError {\n        #[serde(default)]\n        error_code: Option<String>,\n        #[serde(default)]\n        message: Option<String>,\n    }\n    if let Ok(parsed) = serde_json::from_str::<JsonError>(body) {\n        let message = parsed.message.unwrap_or_else(|| body.to_string());\n        (message, parsed.error_code)\n    } else {\n        (body.to_string(), None)","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_client/src/lib.rs#L57-L93","documentation":"This is the IO variant of influxdb3_client::Error, produced via #[from] std::io::Error. It wraps any underlying I/O failure (socket read/write, connection reset, file I/O) that occurs while the HTTP client performs a request. The original std::io::Error is preserved as the error source.","triggerScenarios":"Calling any influxdb3_client HTTP method (query, write line protocol, health/ping, create/delete operations) when the underlying reqwest transport raises an IO error: connection dropped mid-request, DNS/socket failure surfaced as io::Error, or reading a response body from a closed stream.","commonSituations":"Server closed the connection abruptly or restarted mid-request; network interruption, VPN/firewall drop; keep-alive idle connection reused after server timeout; TLS interception proxies terminating the stream; container/OOM killing the server process during a request.","solutions":["Check the error source (std::io::Error) for the root cause (e.g. 'connection reset by peer', 'broken pipe').","Retry the request — transient IO failures on pooled connections are common; use a retry with backoff.","Verify the InfluxDB 3 server URL, port, and that the server is running and reachable (curl the health endpoint).","Disable/inspect proxies or TLS interception; ensure firewall rules allow the connection.","Update reqwest/hyper and the client to pick up connection-pool and keep-alive fixes."],"exampleFix":"// before: unwrap and crash on IO errors\nlet resp = client.api_v3_query_sql(...).await.unwrap();\n// after: handle IO variant with a retry\nmatch client.api_v3_query_sql(...).await {\n    Err(e) if matches!(e, influxdb3_client::Error::IO(_)) => {\n        tokio::time::sleep(Duration::from_secs(1)).await;\n        retry_query().await?;\n    }\n    other => other?,\n}","handlingStrategy":"retry","validationCode":"// pre-flight connectivity check before issuing queries/writes\nasync fn server_reachable(url: &str) -> bool {\n    reqwest::get(format!(\"{url}/health\")).await\n        .map(|r| r.status().is_success())\n        .unwrap_or(false)\n}","typeGuard":"fn is_io_error(e: &influxdb3_client::Error) -> bool {\n    matches!(e, influxdb3_client::Error::IO(_))\n}","tryCatchPattern":"match client.api_v3_query_sql(...).await {\n    Err(e @ influxdb3_client::Error::IO(io)) if io.kind() == std::io::ErrorKind::ConnectionReset => {\n        // transient: retry with backoff\n    }\n    Err(e) => return Err(e.into()),\n    Ok(v) => v,\n}","preventionTips":["Always inspect the #[source] std::io::Error to distinguish transient from permanent failures.","Build retry-with-backoff around client calls; pooled keep-alive connections frequently hit resets.","Health-check the server before long batch operations.","Keep reqwest/hyper updated for connection-pool fixes.","Avoid proxies/TLS interception on the client path, or configure them correctly."],"tags":["network","io","http-client","rust"],"backgroundTag":"http-request-failed","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}