You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the issues of this repository and believe that this is not a duplicate.
Ⅰ. Issue Description
RaftRegistryServiceImpl#acquireClusterMetaData & watch 中,对于出现401情况只进行了重试,但是重试并不代表会触发refreshToken,而绝大多数401来源于token过期,所以应该尽快的重新获取token
In RaftRegistryServiceImpl#acquireClusterMetaData and watch, when a 401 status occurs, only a retry is performed. However, a retry does not necessarily trigger a refreshToken, and the majority of 401 errors stem from token expiration. Therefore, the token should be re-acquired as soon as possible.
private static void acquireClusterMetaData(String clusterName, String group) throws RetryableException {
String tcAddress = queryHttpAddress(clusterName, group);
Map<String, String> header = new HashMap<>();
header.put(HTTP.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.getMimeType());
if (isTokenExpired()) {
refreshToken(tcAddress);
}
if (StringUtils.isNotBlank(jwtToken)) {
header.put(AUTHORIZATION_HEADER, jwtToken);
}
if (StringUtils.isNotBlank(tcAddress)) {
Map<String, String> param = new HashMap<>();
param.put("group", group);
String response = null;
try (CloseableHttpResponse httpResponse =
HttpClientUtil.doGet("http://" + tcAddress + "/metadata/v1/cluster", param, header, 1000)) {
if (httpResponse != null) {
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
response = EntityUtils.toString(httpResponse.getEntity(), StandardCharsets.UTF_8);
} else if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
if (StringUtils.isNotBlank(USERNAME) && StringUtils.isNotBlank(PASSWORD)) {
throw new RetryableException("Authentication failed!");
} else {
throw new AuthenticationFailedException("Authentication failed! you should configure the correct username and password.");
}
}
}
MetadataResponse metadataResponse;
if (StringUtils.isNotBlank(response)) {
try {
metadataResponse = OBJECT_MAPPER.readValue(response, MetadataResponse.class);
METADATA.refreshMetadata(clusterName, metadataResponse);
} catch (JsonProcessingException e) {
LOGGER.error(e.getMessage(), e);
}
}
} catch (IOException e) {
throw new RetryableException(e.getMessage(), e);
}
}
}
Ⅱ. Describe what happened
If there is an exception, please attach the exception trace:
Just paste your stack trace here!
Ⅲ. Describe what you expected to happen
Ⅳ. How to reproduce it (as minimally and precisely as possible)
xxx
xxx
xxx
Minimal yet complete reproducer code (or URL to code):
Ⅴ. Anything else we need to know?
Ⅵ. Environment:
JDK version(e.g. java -version):
Seata client/server version:
Database version:
OS(e.g. uname -a):
Others:
The text was updated successfully, but these errors were encountered:
Ⅰ. Issue Description
RaftRegistryServiceImpl#acquireClusterMetaData & watch 中,对于出现401情况只进行了重试,但是重试并不代表会触发refreshToken,而绝大多数401来源于token过期,所以应该尽快的重新获取token
In RaftRegistryServiceImpl#acquireClusterMetaData and watch, when a 401 status occurs, only a retry is performed. However, a retry does not necessarily trigger a refreshToken, and the majority of 401 errors stem from token expiration. Therefore, the token should be re-acquired as soon as possible.
Ⅱ. Describe what happened
If there is an exception, please attach the exception trace:
Ⅲ. Describe what you expected to happen
Ⅳ. How to reproduce it (as minimally and precisely as possible)
Minimal yet complete reproducer code (or URL to code):
Ⅴ. Anything else we need to know?
Ⅵ. Environment:
java -version
):uname -a
):The text was updated successfully, but these errors were encountered: