{"record":{"id":"dcea5ba01fe7f6cc","repo":"binarywang/WxJava","slug":"error-dcea5b","errorCode":null,"errorMessage":"微信服务端异常，超出重试次数！","messagePattern":"微信服务端异常，超出重试次数！","errorType":"exception","errorClass":"WxErrorException","httpStatus":null,"severity":"error","filePath":"weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java","lineNumber":194,"sourceCode":"    return execute0(executor, uri, data, true);\n  }\n\n  @Override\n  public <T, E> T executeWithoutLog(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException {\n    return execute0(executor, uri, data, false);\n  }\n\n  protected <T, E> T execute0(RequestExecutor<T, E> executor, String uri, E data, boolean printResult)\n    throws WxErrorException {\n    int retryTimes = 0;\n    do {\n      try {\n        return this.executeInternal(executor, uri, data, false, printResult);\n      } catch (WxErrorException e) {\n        if (retryTimes + 1 > this.maxRetryTimes) {\n          log.warn(\"重试达到最大次数【{}】\", maxRetryTimes);\n          //最后一次重试失败后，直接抛出异常，不再等待\n          throw new WxErrorException(WxError.builder()\n            .errorCode(e.getError().getErrorCode())\n            .errorMsg(\"微信服务端异常，超出重试次数！\")\n            .build());\n        }\n\n        WxError error = e.getError();\n        // -1 系统繁忙, 1000ms后重试\n        if (error.getErrorCode() == -1) {\n          int sleepMillis = this.retrySleepMillis * (1 << retryTimes);\n          try {\n            log.warn(\"微信系统繁忙，{} ms 后重试(第{}次)\", sleepMillis, retryTimes + 1);\n            Thread.sleep(sleepMillis);\n          } catch (InterruptedException e1) {\n            Thread.currentThread().interrupt();\n          }\n        } else {\n          throw e;\n        }","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java#L176-L212","documentation":"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.","triggerScenarios":"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.","commonSituations":"WeChat backend incident/oversold; rate limiting presenting as -1; network instability causing repeated failures; default retry budget too low for a sustained outage.","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."],"exampleFix":"// before\n// default maxRetryTimes=5, fails on sustained -1\n// after\nservice.setMaxRetryTimes(10);\nservice.setRetrySleepMillis(2000);\ntry {\n  result = service.getProductService().getProduct(id);\n} catch (WxErrorException e) {\n  // original code preserved in errorCode; handle -1 (busy) vs business errors\n}","handlingStrategy":"try-catch","validationCode":"// Optional: tune retry budget up front\nservice.setMaxRetryTimes(10);\nservice.setRetrySleepMillis(2000);","typeGuard":null,"tryCatchPattern":"try {\n    result = service.getProductService().getProduct(id);\n} catch (WxErrorException e) {\n    int code = e.getError().getErrorCode();\n    if (code == -1) {\n        // sustained system-busy; back off and retry the business op later\n        log.warn(\"WeChat busy after retries, will retry later\", e);\n    } else {\n        // genuine business error from the original code; do not retry blindly\n        log.error(\"Channel call failed with code {}\", code, e);\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["channel","network","retry","transient","runtime"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}