BigPizzaV3/CodexPlusPlus · error

发送微信回复被拒绝:ret= errcode=

Error message

发送微信回复被拒绝:ret={} errcode={} {}

What it means

The WeChat API returned HTTP success but the JSON body indicates a business-level rejection: the WeixinSendResponse has a non-zero ret or errcode (with errmsg detail). The library treats ret!=0 || errcode!=0 as a failed send and surfaces all three fields in the message.

Solutions

  1. Inspect errmsg/errcode in the message; look up the WeChat error code to identify the specific rejection.
  2. Re-login the WeChat session (re-scan QR) if the errcode indicates session/token invalidity.
  3. Reduce send frequency / batch replies if the error is a rate/frequency limit.
  4. Sanitize or shorten message content if the rejection is content-related.
Defensive patterns

Strategy: try-catch

Try / catch

// Rust
if let Err(e) = connector.send_text(text).await {
    let msg = e.to_string();
    if msg.contains("发送微信回复被拒绝") {
        // parse ret/errcode/errmsg, branch on errcode:
        // session invalid -> re-login; content blocked -> sanitize; frequency -> backoff
    }
}

Prevention

When it happens

Trigger: send_text parses the response body into WeixinSendResponse; any body where result.ret != 0 or result.errcode != 0 triggers this bail. Typical errcodes: invalid session, content rejected, frequency limit.

Common situations: WeChat session expired after QR re-login lapse, message content flagged/blocked by WeChat, sending too frequently, or sending to an invalid/disconnected conversation.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/3541cf5f772528ca. Report an issue: GitHub.

Appendix: source

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

            .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> {
        let base = format!("{}/", self.base_url.trim_end_matches('/'));
        reqwest::Url::parse(&base)?
            .join(path.trim_start_matches('/'))
            .context("微信 API 地址无效")
    }

    fn auth_headers(&self) -> anyhow::Result<HeaderMap> {
        let mut headers = self.route_headers(false)?;

View on GitHub (pinned to b1ed92e5e4)