BigPizzaV3/CodexPlusPlus · error · anyhow::Error

发送微信回复失败:HTTP {http_status}

Error message

发送微信回复失败:HTTP {http_status}

What it means

send_text POSTs one reply chunk to the sendmessage endpoint with a 15s timeout and a size-limited response; a non-2xx HTTP status fails the whole send with this error. Empty bodies on 2xx count as success, and JSON bodies with nonzero ret or errcode raise a separate rejected error, so this is purely the HTTP layer.

Source

Thrown at crates/codex-plus-core/src/connect/weixin.rs:298

                    "text_item": { "text": text }
                }],
                "context_token": context_token
            },
            "base_info": { "channel_version": CHANNEL_VERSION }
        });
        let response = self
            .client
            .post(self.endpoint("ilink/bot/sendmessage")?)
            .headers(self.auth_headers()?)
            .json(&request_body)
            .timeout(Duration::from_secs(15))
            .send()
            .await
            .context("发送微信回复失败")?;
        let (http_status, bytes) =
            read_response_limited(response, MAX_SMALL_RESPONSE_BYTES, "微信发送响应").await?;
        if !http_status.is_success() {
            bail!("发送微信回复失败:HTTP {http_status}");
        }
        if bytes.iter().all(u8::is_ascii_whitespace) {
            return Ok(());
        }
        let result: WeixinSendResponse =
            serde_json::from_slice(&bytes).context("微信发送响应格式无效")?;
        if result.ret != 0 || result.errcode != 0 {
            bail!(
                "发送微信回复被拒绝:ret={} errcode={} {}",
                result.ret,
                result.errcode,
                result.errmsg
            );
        }
        Ok(())
    }

    fn endpoint(&self, path: &str) -> anyhow::Result<reqwest::Url> {

View on GitHub (pinned to f2074595a2)

Solutions

  1. Retry after backoff, especially for 429 and 5xx
  2. Re-login when 401 or 403 persists
  3. Slow the chunk cadence or shorten the reply text, the loop already paces 100ms between chunks
  4. Verify the token and route headers
Defensive patterns

Strategy: retry

Try / catch

for chunk in chunk_text(&reply, MAX_REPLY_CHARS) {
    if let Err(e) = client.send_text_chunks(&peer, &chunk, token).await {
        if e.to_string().contains("HTTP 4") || e.to_string().contains("HTTP 5") {
            tokio::time::sleep(Duration::from_secs(1)).await;
            client.send_text_chunks(&peer, &chunk, token).await?;
        } else { return Err(e); }
    }
}

Prevention

When it happens

Trigger: The gateway rejects the send at HTTP level: expired token (401), rate limiting (429), an oversized or invalid chunk, or 5xx during maintenance.

Common situations: Rapid multi-chunk replies tripping rate limits; the session expired between receive and reply; ilink outage.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@f2074595a2 (2026-08-23). Data as JSON: /api/errors/e6d65bdd80768aa6. Report an issue: GitHub.