{"record":{"id":"3755506dd095fe0f","repo":"binarywang/WxJava","slug":"error-375550","errorCode":null,"errorMessage":"错误代码：{}, 错误信息：{}","messagePattern":"错误代码：(.+?), 错误信息：(.+?)","errorType":"exception","errorClass":"WxErrorException","httpStatus":null,"severity":"critical","filePath":"weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceHttpComponentsImpl.java","lineNumber":71,"sourceCode":"    synchronized (this.globalSuiteAccessTokenRefreshLock) {\n      try {\n        HttpPost httpPost = new HttpPost(configStorage.getApiUrl(WxCpApiPathConsts.Tp.GET_SUITE_TOKEN));\n        if (this.httpProxy != null) {\n          RequestConfig config = RequestConfig.custom()\n            .setProxy(this.httpProxy).build();\n          httpPost.setConfig(config);\n        }\n        JsonObject jsonObject = new JsonObject();\n        jsonObject.addProperty(\"suite_id\", this.configStorage.getSuiteId());\n        jsonObject.addProperty(\"suite_secret\", this.configStorage.getSuiteSecret());\n        jsonObject.addProperty(\"suite_ticket\", this.getSuiteTicket());\n        StringEntity entity = new StringEntity(jsonObject.toString(), StandardCharsets.UTF_8);\n        httpPost.setEntity(entity);\n\n        String resultContent = getRequestHttpClient().execute(httpPost, BasicResponseHandler.INSTANCE);\n        WxError error = WxError.fromJson(resultContent, WxType.CP);\n        if (error.getErrorCode() != 0) {\n          throw new WxErrorException(error);\n        }\n        jsonObject = GsonParser.parse(resultContent);\n        String suiteAccussToken = jsonObject.get(\"suite_access_token\").getAsString();\n        int expiresIn = jsonObject.get(\"expires_in\").getAsInt();\n        this.configStorage.updateSuiteAccessToken(suiteAccussToken, expiresIn);\n      } catch (IOException e) {\n        throw new WxRuntimeException(e);\n      }\n    }\n    return this.configStorage.getSuiteAccessToken();\n  }\n\n  @Override\n  public void initHttp() {\n    HttpComponentsClientBuilder apacheHttpClientBuilder = DefaultHttpComponentsClientBuilder.get();\n\n    apacheHttpClientBuilder.httpProxyHost(this.configStorage.getHttpProxyHost())\n            .httpProxyPort(this.configStorage.getHttpProxyPort())","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceHttpComponentsImpl.java#L53-L89","documentation":"Thrown as WxErrorException when the HttpComponents (HC5) implementation of getSuiteAccessToken() receives a non-zero error code from the suite_access_token endpoint. Identical logic to the Apache HttpClient variant (error 164) but uses Apache HttpComponents 5.x as the transport. The request posts suite_id, suite_secret, and suite_ticket.","triggerScenarios":"Suite access token request fails with errcode != 0: invalid suite_secret (640001), expired suite_ticket (40029), invalid suite_id (40098), or IP whitelist violation (60020).","commonSituations":"suite_secret mismatch; suite_ticket expired or not received; server IP not in whitelist; suite application under review or revoked.","solutions":["Verify suite_id and suite_secret exactly match the Third-Party Platform console settings","Ensure suite_ticket is being received and stored before it expires (2-hour validity, pushed every 10 min)","Whitelist your server's public IP in the WeChat TP admin console","Inspect WxError errorCode for the specific failure reason"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify suite credentials before relying on token auto-refresh\nif (StringUtils.isBlank(configStorage.getSuiteId())\n    || StringUtils.isBlank(configStorage.getSuiteSecret())) {\n  throw new IllegalStateException(\"suite_id and suite_secret must be configured\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  service.getSuiteAccessToken();\n} catch (WxErrorException e) {\n  WxError error = e.getError();\n  log.error(\"HttpComponents suite token error: code={}, msg={}\",\n    error.getErrorCode(), error.getErrorMsg());\n  throw e;\n}","preventionTips":["Verify suite_id and suite_secret match the TP console","Ensure suite_ticket callback is functional and tickets are refreshed every 10 min","Whitelist your server IP in the WeChat TP admin console","Monitor token acquisition metrics and set up alerting"],"tags":["token","weixin-cp","suite-access-token","authentication","httpcomponents","tp"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}