{"record":{"id":"450b856e4b817565","repo":"binarywang/WxJava","slug":"error-450b85","errorCode":null,"errorMessage":"微信服务端异常，超出重试次数","messagePattern":"微信服务端异常，超出重试次数","errorType":"exception","errorClass":"WxRuntimeException","httpStatus":null,"severity":"error","filePath":"weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java","lineNumber":353,"sourceCode":"    String urlWithToken = url + (url.contains(\"?\") ? \"&\" : \"?\") + \"access_token=\" + contactAccessToken;\n    // 使用executeNormal方法，不自动添加token\n    return this.executeNormal(SimplePostRequestExecutor.create(this), urlWithToken, postData);\n  }\n\n  /**\n   * 向微信端发送请求，在这里执行的策略是当发生access_token过期时才去刷新，然后重新执行请求，而不是全局定时请求.\n   */\n  @Override\n  public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException {\n    int retryTimes = 0;\n    do {\n      try {\n        return this.executeInternal(executor, uri, data, false);\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":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java#L335-L371","documentation":"Thrown inside the retry loop of BaseCpServiceImpl.execute() when a retried call fails again and retryTimes + 1 exceeds maxRetryTimes. Only the errcode == -1 (WeChat 'system busy') branch is retried; once retries run out on that branch the original WxErrorException is discarded and replaced with WxRuntimeException('微信服务端异常，超出重试次数').","triggerScenarios":"WeChat returning errcode -1 (system busy) persistently across all retry attempts; maxRetryTimes configured too low for a prolonged WeChat degradation.","commonSituations":"WeChat-side incident causing sustained -1 responses; retrySleepMillis/maxRetryTimes misconfigured (too few retries or too short backoff); high-traffic windows hitting WeChat rate pressure.","solutions":["Tune maxRetryTimes and retrySleepMillis so the backoff covers transient WeChat degradation.","Catch WxRuntimeException here and surface a 'service temporarily unavailable' to the caller with retry guidance.","Check WeChat platform status and your app's call volume/rate limits.","Note this masks the original WxErrorException - log errcode/-1 context before the throw is lost."],"exampleFix":"// before\nresult = service.execute(executor, uri, data);\n// after\ntry {\n  result = service.execute(executor, uri, data);\n} catch (WxRuntimeException e) {\n  if (\"微信服务端异常，超出重试次数\".equals(e.getMessage())) {\n    throw new ServiceUnavailableException(\"WeChat busy, retry later\", e);\n  }\n  throw e;\n}","handlingStrategy":"retry","validationCode":"if (service.getMaxRetryTimes() <= 0) {\n  // configure retries for -1 system-busy responses\n  log.warn(\"no retries configured; WeChat busy will surface as runtime error\");\n}","typeGuard":"null","tryCatchPattern":"try {\n  result = service.execute(executor, uri, data);\n} catch (WxRuntimeException e) {\n  if (\"微信服务端异常，超出重试次数\".equals(e.getMessage())) {\n    throw new ServiceUnavailableException(\"WeChat busy, retry later\", e);\n  }\n  throw e;\n}","preventionTips":["Configure maxRetryTimes/retrySleepMillis for -1 backoff.","Translate the runtime exception to a domain 'try later' for callers.","Monitor WeChat status and throttle during incidents."],"tags":["weixin-api","retry","cp","rate-limit","network"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}