{"record":{"id":"b06ede76d98341d2","repo":"binarywang/WxJava","slug":"error-b06ede","errorCode":null,"errorMessage":"微信服务端异常，超出重试次数","messagePattern":"微信服务端异常，超出重试次数","errorType":"exception","errorClass":"WxRuntimeException","httpStatus":null,"severity":"error","filePath":"weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImpl.java","lineNumber":399,"sourceCode":"   * @param <T>                     the type parameter\n   * @param <E>                     the type parameter\n   * @param executor                the executor\n   * @param uri                     the uri\n   * @param data                    the data\n   * @param withoutSuiteAccessToken the without suite access token\n   * @return the t\n   * @throws WxErrorException the wx error exception\n   */\n  public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data, boolean withoutSuiteAccessToken) throws WxErrorException {\n    int retryTimes = 0;\n    do {\n      try {\n        return this.executeInternal(executor, uri, data, withoutSuiteAccessToken);\n      } catch (WxErrorException e) {\n        if (retryTimes + 1 > this.maxRetryTimes) {\n          log.warn(\"重试达到最大次数【{}】\", this.maxRetryTimes);\n          //最后一次重试失败后，直接抛出异常，不再等待\n          throw new WxRuntimeException(\"微信服务端异常，超出重试次数\");\n        }\n\n        WxError error = e.getError();\n        /*\n         * -1 系统繁忙, 1000ms后重试\n         */\n        if (error.getErrorCode() == -1) {\n          int sleepMillis = this.retrySleepMillis * (1 << retryTimes);\n          try {\n            log.debug(\"微信系统繁忙，{} ms 后重试(第{}次)\", sleepMillis, retryTimes + 1);\n            Thread.sleep(sleepMillis);\n          } catch (InterruptedException e1) {\n            Thread.currentThread().interrupt();\n          }\n        } else {\n          throw e;\n        }\n      }","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImpl.java#L381-L417","documentation":"Thrown as WxRuntimeException when the CP Third-Party Platform (TP) service exhausts all retry attempts in the execute() method. The retry loop only retries on WeChat error code -1 (system busy) with exponential backoff (retrySleepMillis * 2^retryTimes). When retryTimes + 1 exceeds maxRetryTimes, the original WxErrorException is discarded and replaced with this generic runtime exception.","triggerScenarios":"WeChat CP TP API endpoint repeatedly returns errcode -1 (system busy) across every retry attempt. The throw fires inside the catch block at line 399 when retryTimes + 1 > maxRetryTimes evaluates true.","commonSituations":"WeChat backend sustained outage or maintenance window; unstable network proxy causing repeated timeouts; maxRetryTimes set too low (default 5); high-frequency API calls during WeChat peak traffic.","solutions":["Check WeChat platform status for ongoing outages or maintenance windows","Increase retry budget: service.setMaxRetryTimes(10) and service.setRetrySleepMillis(2000)","Verify network stability and proxy configuration between your server and qyapi.weixin.qq.com","Implement a circuit breaker (e.g., Resilience4j) to fail-fast during sustained outages instead of burning all retries"],"exampleFix":"// before\nservice.setMaxRetryTimes(5);\nservice.setRetrySleepMillis(1000);\n\n// after\nservice.setMaxRetryTimes(10);\nservice.setRetrySleepMillis(2000);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  service.execute(executor, uri, data);\n} catch (WxRuntimeException e) {\n  if (e.getMessage().contains(\"超出重试次数\")) {\n    // All retries exhausted on errcode -1\n    log.error(\"WeChat CP API unavailable after retries\", e);\n    // fall back to cached data, queue for later, or alert\n  } else {\n    throw e;\n  }\n}","preventionTips":["Tune maxRetryTimes and retrySleepMillis based on your latency budget","Monitor WeChat platform status dashboards and set up alerts","Use a circuit breaker to fail-fast during sustained outages instead of burning all retries","Log retry attempts to distinguish transient issues from persistent failures"],"tags":["retry","network","weixin-cp","system-busy","tp"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}