binarywang/WxJava · error · WxErrorException

微信服务端异常,超出重试次数!

Error message

微信服务端异常,超出重试次数!

What it means

Thrown as WxErrorException when the MiniApp service exhausts all retry attempts for error code -1 (system busy). Unlike the CP variant (error 160), this preserves the original error code via a custom WxError object. The message has a trailing '!' to distinguish it from error 172's WxRuntimeException.

Source

Thrown at weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java:398

        uri,
        dataForLog);
  }

  private static interface ExecutorAction<R> {
    R execute(String urlWithAccessToken) throws IOException, WxErrorException;
  }

  private <R, T> R executeWithRetry(ExecutorAction<R> executor, String uri, String dataForLog)
      throws WxErrorException {
    int retryTimes = 0;
    do {
      try {
        return this.executeInternal(executor, uri, dataForLog, false);
      } 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

  1. Check WeChat MiniApp platform status for ongoing outages
  2. Increase retry budget: service.setMaxRetryTimes(10) and service.setRetrySleepMillis(2000)
  3. Reduce API call frequency during peak hours to avoid -1 system busy responses
  4. Implement a circuit breaker pattern (e.g., Resilience4j) for sustained outage resilience

Example fix

// before
wxMaService.setMaxRetryTimes(5);

// after
wxMaService.setMaxRetryTimes(10);
wxMaService.setRetrySleepMillis(2000);
Defensive patterns

Strategy: try-catch

Try / catch

try {
  wxMaService.execute(executor, uri);
} catch (WxErrorException e) {
  if ("微信服务端异常,超出重试次数!".equals(e.getError().getErrorMsg())) {
    log.error("MiniApp API unavailable after {} retries", maxRetryTimes);
    // fall back to cached data, queue for later, or alert
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: WeChat MiniApp API repeatedly returns errcode -1 (system busy) across all retry attempts with exponential backoff in executeWithRetry(). The throw fires at line 398 when retryTimes + 1 > maxRetryTimes.

Common situations: WeChat backend instability; high-frequency MiniApp API calls during peak traffic; maxRetryTimes set too low; rate limiting manifesting as -1 errors.

Related errors


AI-assisted analysis of binarywang/WxJava@1c43293a3c (2026-08-14). Data as JSON: /api/errors/0289b0a25aa88c9c. Report an issue: GitHub.