BigPizzaV3/CodexPlusPlus · error
微信长轮询被拒绝:ret= errcode=
Error message
微信长轮询被拒绝:ret={} errcode={} {} What it means
Even with HTTP 200, the WeChat long-poll body carries an application-level result code; get_updates deserializes WeixinUpdates and requires ret == 0 and errcode == 0, otherwise bailing with this message that embeds ret, errcode and errmsg. This distinguishes WeChat-side business rejections (auth, kicked session, invalid params) from transport errors.
Solutions
- Read errmsg in the message — it names the WeChat-side cause (e.g. invalid session, kicked)
- Re-run the QR login flow to obtain a fresh token and restart the bridge
- Check errmsg against current WeChat API docs for schema/param changes
- Stop the poll loop instead of hot-retrying on persistent non-zero ret to avoid lockouts
Example fix
// before
let updates = client.get_updates(&token, &cursor).await?; // bails on ret!=0, loop spins
// after
let updates = client.get_updates(&token, &cursor).await.map_err(|e| {
if e.to_string().contains("微信长轮询被拒绝") {
anyhow!("会话失效({e:#}),需重新扫码登录")
} else { e }
})?; Defensive patterns
Strategy: try-catch
Validate before calling
// nothing to pre-validate: ret/errcode are server-side; parse defensively let updates: WeixinUpdates = serde_json::from_slice(&bytes)?; let ok = updates.ret == 0 && updates.errcode == 0;
Type guard
fn updates_accepted(u: &WeixinUpdates) -> bool { u.ret == 0 && u.errcode == 0 } Try / catch
match get_updates(&token, &cursor).await {
Err(e) if e.to_string().contains("微信长轮询被拒绝") => {
let msg = e.to_string();
if msg.contains("token") || msg.contains("kicked") { restart_login(); } else { log_and_pause(); }
}
other => other?,
} Prevention
- Parse errmsg and branch on known WeChat business codes
- Stop/re-login on persistent rejections instead of hot-retrying
- Keep the token in sync with logins from other devices
- Track WeChat API changelogs for ret/errcode semantics
When it happens
Trigger: Calling get_updates when the WeChat API responds 200 with a non-zero ret or errcode — typically an invalid/expired token, the session being kicked by another login, or malformed request parameters.
Common situations: User re-logged-in on another device invalidating this session; token rotated and the old one still in use; WeChat-side parameter/API change reflected in errmsg; account restrictions.
Related errors
- 微信长轮询请求失败:HTTP
- API 未能生成本批整理结果
- 官方混合 API 不应在 auth.json 中保存 OPENAI_API_KEY。请清理此供应商的…
- API 输出达到长度上限,本批未提交;请使用输出容量更大的模型
- API 未返回有效的 choices[0].message.content,请确认兼容 Chat Completions
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/8f7441054af67008.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/connect/weixin.rs:239
ret: 0,
errcode: 0,
errmsg: String::new(),
messages: Vec::new(),
get_updates_buf: get_updates_buf.to_string(),
longpolling_timeout_ms: timeout_ms,
});
}
Err(error) => return Err(error).context("微信长轮询请求失败"),
};
let (http_status, bytes) =
read_response_limited(response, MAX_API_RESPONSE_BYTES, "微信长轮询").await?;
if !http_status.is_success() {
bail!("微信长轮询请求失败:HTTP {http_status}");
}
let updates: WeixinUpdates =
serde_json::from_slice(&bytes).context("微信长轮询响应格式无效")?;
if updates.ret != 0 || updates.errcode != 0 {
bail!(
"微信长轮询被拒绝:ret={} errcode={} {}",
updates.ret,
updates.errcode,
updates.errmsg
);
}
Ok(updates)
}
pub async fn send_text_chunks(
&self,
to_user_id: &str,
text: &str,
context_token: &str,
) -> anyhow::Result<()> {
if context_token.trim().is_empty() {
bail!("微信回复缺少 context_token");
}View on GitHub (pinned to b1ed92e5e4)