<ul dir="auto">
<li>[ √] 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>[ √] 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: 2.7.1</li>
<li>Operating System version: Mac OS</li>
<li>Java version: 1.8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>使用nacos作为注册中心，集群部署</li>
<li>想同时注册到同一nacos下 不同namespace</li>
<li>参考了官方文档只提供了配置如下<br>
nacos://xxxx:8848?namespace=xxxx<br>
或者<br>
nacos://xxxx:8848?backup=xxxx:8850<br>
即单个namespace或不带namespace时使用backup是生效的</li>
</ol>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">配置如下 则无法成功注册<br>
xxxx?namespace=111?backup=xxx?namespace=222</p>
<p dir="auto">What do you expected from the above steps？</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">不合法的参数<br>
What actually happens?<br>
在参考<a href="https://github.com/apache/dubbo/issues/4207" data-hovercard-type="issue" data-hovercard-url="/apache/dubbo/issues/4207/hovercard">#4207</a>升级为2.7.6后也是如此。<br>
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>
<p dir="auto">是否进行心跳信息的发送，是靠下面两个属性来判断的。<br>
Long lastRead = (Long) channel.getAttribute(HeaderExchangeHandler.KEY_READ_TIMESTAMP);<br>
Long lastWrite = (Long) channel.getAttribute(HeaderExchangeHandler.KEY_WRITE_TIMESTAMP);</p>
<p dir="auto">KEY_READ_TIMESTAMP与KEY_WRITE_TIMESTAMP的设置在HeartBeatHandler和HeaderExchangeHandler中都做了一遍。</p>
<p dir="auto">在HeartBeatHandler中：（代码较多，就不贴了）</p>
<ul dir="auto">
<li>连接完成时：设置lastRead和lastWrite</li>
<li>连接断开时：清空lastRead和lastWrite</li>
<li>发送消息时：设置lastWrite</li>
<li>接收消息时：设置lastRead</li>
</ul>
<p dir="auto">在HeaderExchangeHandler中：（代码较多，就不贴了）</p>
<ul dir="auto">
<li>连接完成时：设置lastRead和lastWrite</li>
<li>连接断开时：也设置而非清空lastRead和lastWrite</li>
<li>发送消息时：设置lastWrite</li>
<li>接收消息时：设置lastRead</li>
</ul>
<p dir="auto">而我们构建的nettyHandler的调用链是这样的：<br>
MultiMessageHandler-&gt;<strong>HeartbeatHandler</strong>-&gt;AllChannelHandler-&gt;DecodeHandler-&gt; <strong>HeaderExchangeHandler</strong>-&gt;ExchangeHandlerAdapter（DubboProtocol.requestHandler）</p>
<p dir="auto">也就是说每次请求和响应都会走这个链路，那么HeartbeatHandler设置了KEY_READ_TIMESTAMP与KEY_WRITE_TIMESTAMP后，HeaderExchangeHandler为什么还要设置一遍？而且在HeaderExchangeHandler中断开连接的时候为什么是设置而非清空lastRead和lastWrite？</p>