binarywang/WxJava · error · WxErrorException
微信服务端异常,超出重试次数!
Error message
微信服务端异常,超出重试次数!
What it means
Thrown by the Channel (视频号) service's `execute0` retry loop when a request keeps failing past `maxRetryTimes` (default 5). On WeChat error code `-1` (系统繁忙/system busy) the SDK sleeps `retrySleepMillis * 2^retryTimes` (default base 1000ms) and retries; once retries are exhausted it rethrows a WxErrorException whose errorCode is the original but whose errorMsg is replaced with this message.
Source
Thrown at weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java:194
return execute0(executor, uri, data, true);
}
@Override
public <T, E> T executeWithoutLog(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException {
return execute0(executor, uri, data, false);
}
protected <T, E> T execute0(RequestExecutor<T, E> executor, String uri, E data, boolean printResult)
throws WxErrorException {
int retryTimes = 0;
do {
try {
return this.executeInternal(executor, uri, data, false, printResult);
} catch (WxErrorException e) {
if (retryTimes + 1 > this.maxRetryTimes) {
log.warn("重试达到最大次数【{}】", maxRetryTimes);
//最后一次重试失败后,直接抛出异常,不再等待
throw new WxErrorException(WxError.builder()
.errorCode(e.getError().getErrorCode())
.errorMsg("微信服务端异常,超出重试次数!")
.build());
}
WxError error = e.getError();
// -1 系统繁忙, 1000ms后重试
if (error.getErrorCode() == -1) {
int sleepMillis = this.retrySleepMillis * (1 << retryTimes);
try {
log.warn("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1);
Thread.sleep(sleepMillis);
} catch (InterruptedException e1) {
Thread.currentThread().interrupt();
}
} else {
throw e;
}View on GitHub (pinned to 1c43293a3c)
Solutions
- Treat as transient: back off and retry the whole operation later; check WeChat platform status.
- Increase budget: `service.setMaxRetryTimes(10)` and/or `service.setRetrySleepMillis(2000)`.
- Capture the original errorCode from `e.getError().getErrorCode()` to distinguish -1 from other codes.
- If non-`-1` codes are surfacing here, fix the underlying request (bad params/permissions) rather than retrying.
Example fix
// before
// default maxRetryTimes=5, fails on sustained -1
// after
service.setMaxRetryTimes(10);
service.setRetrySleepMillis(2000);
try {
result = service.getProductService().getProduct(id);
} catch (WxErrorException e) {
// original code preserved in errorCode; handle -1 (busy) vs business errors
} Defensive patterns
Strategy: try-catch
Validate before calling
// Optional: tune retry budget up front service.setMaxRetryTimes(10); service.setRetrySleepMillis(2000);
Try / catch
try {
result = service.getProductService().getProduct(id);
} catch (WxErrorException e) {
int code = e.getError().getErrorCode();
if (code == -1) {
// sustained system-busy; back off and retry the business op later
log.warn("WeChat busy after retries, will retry later", e);
} else {
// genuine business error from the original code; do not retry blindly
log.error("Channel call failed with code {}", code, e);
}
throw e;
} Prevention
- Differentiate errcode -1 (transient) from real business errors via getErrorCode().
- Raise maxRetryTimes only when you genuinely expect longer -1 outages.
- Monitor -1 rates as an early signal of WeChat-side incidents.
- Wrap idempotent calls in an outer retry-with-backoff distinct from the SDK's internal retry.
When it happens
Trigger: Any Channel API call when the WeChat server persistently returns errcode `-1` for more than `maxRetryTimes` consecutive attempts; or when the retried exception is not a `-1` but `retryTimes + 1 > maxRetryTimes` on the final iteration.
Common situations: WeChat backend incident/oversold; rate limiting presenting as -1; network instability causing repeated failures; default retry budget too low for a sustained outage.
Related errors
AI-assisted analysis of binarywang/WxJava@1c43293a3c (2026-08-14).
Data as JSON: /api/errors/dcea5ba01fe7f6cc.
Report an issue: GitHub.