Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Nacos reconnection failed continuously issue with message "com.alibaba.nacos.common.remote.exception.RemoteException: errCode: 500, errMsg: Unknown payload type:ServerCheckResponse" but actually the connection is already established. #1676

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,16 @@ private NamingServiceUtils() {
public static NamingService buildNamingService(Map<String, String> parameters, NacosRegisterConfig registerConfig,
RegisterServiceCommonConfig commonConfig) {
Properties nacosProperties = buildNacosProperties(parameters, registerConfig, commonConfig);
ClassLoader tempClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(NamingServiceUtils.class.getClassLoader());
try {
return NacosFactory.createNamingService(nacosProperties);
} catch (NacosException e) {
LOGGER.log(Level.SEVERE, String.format(Locale.ENGLISH, "create namingService failed: {%s}",
e.getErrMsg()), e);
throw new IllegalStateException(e);
} finally {
Thread.currentThread().setContextClassLoader(tempClassLoader);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,23 @@ private void buildNamingService(Properties properties) throws NacosException {
}

private NamingService createNewNamingService(Properties properties) throws NacosException {
return new NacosNamingService(properties);
ClassLoader tempClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
try {
return new NacosNamingService(properties);
} finally {
Thread.currentThread().setContextClassLoader(tempClassLoader);
}
}

private NamingMaintainService createNamingMaintainService(Properties properties) throws NacosException {
return new NacosNamingMaintainService(properties);
ClassLoader tempClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
try {
return new NacosNamingMaintainService(properties);
} finally {
Thread.currentThread().setContextClassLoader(tempClassLoader);
}
}

/**
Expand Down
Loading