<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/apache/incubator-dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/apache/incubator-dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: 2.6.2</li>
<li>域名解析示例：<br>
10.0.0.1 zk.foo.com<br>
10.0.0.2 zk.foo.com<br>
10.0.0.3 zk.foo.com<br>
10.0.0.4 zk.foo.com<br>
10.0.0.5 zk.foo.com</li>
<li>注册中心：zookeeper</li>
</ul>
<p dir="auto">在生产环境中要求只能使用域名，注册中心的域名解析如示例中所示，Dubbo框架在创建注册中心时，会对域名进行解析，且只取其中一个IP，这会导致每次解析获得的IP有可能不一样，有可能出现如下问题：<br>
1、解析获取到不一样的IP的时候，会再次创建一个注册中心实例，导致和注册中心建立多个连接。<br>
2、如果始终解析到的是一个IP，如果该注册中心节点不可以，zookeeper客户端也没有可重试的IP，那么会导致应用与注册中心的会话失效，导致临时服务节点被删除。<br>
下面是获取注册中心Key的代码:<br>
<a href="https://github.com/apache/incubator-dubbo/blob/e6b0bc8a856abd7f2d7a2e0f06ccc78dc90e2e0a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java#L88">https://github.com/apache/incubator-dubbo/blob/e6b0bc8a856abd7f2d7a2e0f06ccc78dc90e2e0a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java#L88</a><br>
就是在该方法中将域名解析成单一的IP，是否可以考虑将该实现换成不解析域名的方法：<br>
<a href="https://github.com/apache/incubator-dubbo/blob/7a48fac84b14ac6a21c1bdfc5958705dd8dda84d/dubbo-compatible/src/main/java/com/alibaba/dubbo/common/URL.java#L498-L500">https://github.com/apache/incubator-dubbo/blob/7a48fac84b14ac6a21c1bdfc5958705dd8dda84d/dubbo-compatible/src/main/java/com/alibaba/dubbo/common/URL.java#L498-L500</a><br>
将域名解析的任务交给zookeeper客户端完成，zookeeper客户端默认会将域名解析成IP列表。</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have searched the <a href="https://github.com/apache/dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the <a href="https://github.com/apache/dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: xxx</li>
<li>Operating System version: xxx</li>
<li>Java version: xxx</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>xxx</li>
<li>xxx</li>
<li>xxx</li>
</ol>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">What do you expected from the above steps？</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">What actually happens?</p>
<p dir="auto">If there is an exception, please attach the exception trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Just put your stack trace here!"><pre class="notranslate"><code class="notranslate">Just put your stack trace here!
</code></pre></div>