{"record":{"id":"db18fda5de281421","repo":"BigPizzaV3/CodexPlusPlus","slug":"http-http-status","errorCode":null,"errorMessage":"微信长轮询请求失败：HTTP {http_status}","messagePattern":"微信长轮询请求失败：HTTP (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/connect/weixin.rs","lineNumber":234,"sourceCode":"            .await;\n        let response = match response {\n            Ok(response) => response,\n            Err(error) if error.is_timeout() => {\n                return Ok(WeixinUpdates {\n                    ret: 0,\n                    errcode: 0,\n                    errmsg: String::new(),\n                    messages: Vec::new(),\n                    get_updates_buf: get_updates_buf.to_string(),\n                    longpolling_timeout_ms: timeout_ms,\n                });\n            }\n            Err(error) => return Err(error).context(\"微信长轮询请求失败\"),\n        };\n        let (http_status, bytes) =\n            read_response_limited(response, MAX_API_RESPONSE_BYTES, \"微信长轮询\").await?;\n        if !http_status.is_success() {\n            bail!(\"微信长轮询请求失败：HTTP {http_status}\");\n        }\n        let updates: WeixinUpdates =\n            serde_json::from_slice(&bytes).context(\"微信长轮询响应格式无效\")?;\n        if updates.ret != 0 || updates.errcode != 0 {\n            bail!(\n                \"微信长轮询被拒绝：ret={} errcode={} {}\",\n                updates.ret,\n                updates.errcode,\n                updates.errmsg\n            );\n        }\n        Ok(updates)\n    }\n\n    pub async fn send_text_chunks(\n        &self,\n        to_user_id: &str,\n        text: &str,","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/connect/weixin.rs#L216-L252","documentation":"get_updates performs a long-poll for new WeChat messages; when the HTTP response status is not success it bails with this message including the status. The body-size-capped read succeeds but the status check rejects it, so no deserialization is attempted. Transport-level errors carry a different context ('微信长轮询请求失败' via .context).","triggerScenarios":"Calling get_updates when the WeChat long-poll endpoint returns 4xx/5xx: invalid/expired token, over-frequent polling (429), or server errors; also proxies intercepting with 502/504.","commonSituations":"Token expired after re-login elsewhere (401); polling loop too tight (429); gateway timeouts on long-poll (504) from aggressive proxy timeouts shorter than the long-poll window.","solutions":["Inspect the status: 401/403 → re-run QR login for a fresh token; 429 → slow the poll loop; 5xx/504 → retry with backoff","Ensure any reverse proxy in front allows long-poll durations (raise proxy read timeout)","Verify the device/token pairing hasn't been invalidated by a parallel login","Add retry-with-backoff around get_updates in the polling loop"],"exampleFix":"// before\nlet updates = client.get_updates(&token, &cursor).await?; // aborts poll loop on any 5xx\n// after\nlet updates = match client.get_updates(&token, &cursor).await {\n    Err(e) if e.to_string().contains(\"HTTP 5\") => { backoff().await; continue; }\n    Err(e) if e.to_string().contains(\"HTTP 401\") => return Err(anyhow!(\"登录失效，请重新扫码\")),\n    other => other?,\n};","handlingStrategy":"retry","validationCode":"// ensure the token is present before long-polling\nanyhow::ensure!(!token.trim().is_empty(), \"长轮询前需要有效会话 token\");","typeGuard":null,"tryCatchPattern":"match get_updates(&token, &cursor).await {\n    Err(e) if e.to_string().contains(\"HTTP 5\") || e.to_string().contains(\"HTTP 504\") => { backoff().await; continue; }\n    Err(e) if e.to_string().contains(\"HTTP 401\") => restart_login(),\n    other => other?,\n}","preventionTips":["Configure proxies to tolerate long-poll durations","Back off on 5xx instead of tight-looping","Re-login on auth statuses instead of hammering","Monitor poll error rates for API regressions"],"tags":["http","wechat","long-polling","network"],"backgroundTag":"http-error-response","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}