<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">Steps to reproduce this issue</h3>
<p dir="auto">Now the travis ci of master branch failed<br>
<a href="https://api.travis-ci.org/v3/job/471789633/log.txt" rel="nofollow">https://api.travis-ci.org/v3/job/471789633/log.txt</a></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/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"> 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.5.3</li>
<li>Operating System version: centos7</li>
<li>Java version: jdk8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>服务发布时，使用kill -15或者kill -9杀死老进程，然后启动服务，dubbo对外服务端口处于Linux系统临时端口范围内；</li>
<li>启动过程中偶尔会报 <code class="notranslate">Address already in use: bind</code> 异常，概率很低；</li>
<li>如果这种问题出现，需要重新发布或者重启下服务，不太友好 :(</li>
</ol>
<h3 dir="auto">问题分析</h3>
<p dir="auto">dubbo服务监听端口处于Linux系统临时端口范围内，从老进程被kill掉，到新进程启动，这段时间内可能该端口已被系统分配给其他进程作为临时端口使用了，导致服务启动不了，本地已验证。（ps：该问题还有可能是其他原因导致，不过暂时没有分析出来）</p>
<p dir="auto">如何解决：</p>
<ol dir="auto">
<li>dubbo对外监听端口不要设置在Linux临时端口范围，或者将Linux临时端口范围设置成不包括服务对外监听端口。</li>
<li>dubbo启动过程中可以对绑定端口做容错处理，该容错功能可默认不启用，启用时如果报了端口被占用异常，可以在原有端口上做自增然后再次尝试。（看了目前dubbo的代码）</li>
</ol>
<p dir="auto">ps：可以将端口配置-1让dubbo选择临时端口作为监听端口，不过我们服务目前都是指定固定端口。</p>
<blockquote>
<p dir="auto">因此，dubbo后续是否可以考虑增加一个对端口占用容错的特性呢，谢谢~</p>
</blockquote>