diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java b/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java index f196443db6e..8a91e965ae8 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java @@ -48,7 +48,9 @@ import java.io.IOException; import java.io.StringReader; +import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; +import java.net.URLEncoder; import java.util.*; import java.util.concurrent.*; @@ -327,7 +329,11 @@ public JSONObject sendBeat(BeatInfo beatInfo, boolean lightBeatEnabled) throws N Map params = new HashMap(8); String body = StringUtils.EMPTY; if (!lightBeatEnabled) { - body = "beat=" + JSON.toJSONString(beatInfo); + try { + body = "beat=" + URLEncoder.encode(JSON.toJSONString(beatInfo), "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new NacosException(NacosException.SERVER_ERROR, "encode beatInfo error", e); + } } params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, beatInfo.getServiceName());