docker环境下,无法连接server,导致获取不到配置,然后应用启动失败。 nacos Server 和 nacos客户端都是2.0.1版本 同一台机器下,部署多个应用,有些应用可以连接,有些不能连接
确认所有的端口都是开放的。
只要我往com.alibaba.nacos.common.remote.client.RpcClient 这个类的start 方法里面打断点,就能连上并启动成功。放开断点,去启动就是以下报错。所以一debug,问题就无法复现
Dec 02 13:59:08 suninfo-omaudit startoma[10734]: 2021-12-02 13:59:08.466 ERROR 10734 --- [ restartedMain] com.alibaba.nacos.common.remote.client : Send request fail, request=ConfigQueryRequest{headers={charset=UTF-8, exConfigInfo=true, Client-AppName=unknown, Client-RequestTS=1638424748277, Client-RequestToken=b06a49491808064535b9f18840d42c50, Timestamp=1638424748280, notify=false}, requestId='null'}, retryTimes=0,errorMessage=Client not connected,current status:STARTING Dec 02 13:59:08 suninfo-omaudit startoma[10734]: 2021-12-02 13:59:08.568 ERROR 10734 --- [ restartedMain] com.alibaba.nacos.common.remote.client : Send request fail, request=ConfigQueryRequest{headers={charset=UTF-8, exConfigInfo=true, Client-AppName=unknown, Client-RequestTS=1638424748277, Client-RequestToken=b06a49491808064535b9f18840d42c50, Timestamp=1638424748280, notify=false}, requestId='null'}, retryTimes=1,errorMessage=Client not connected,current status:STARTING Dec 02 13:59:08 suninfo-omaudit startoma[10734]: 2021-12-02 13:59:08.669 ERROR 10734 --- [ restartedMain] com.alibaba.nacos.common.remote.client : Send request fail, request=ConfigQueryRequest{headers={charset=UTF-8, exConfigInfo=true, Client-AppName=unknown, Client-RequestTS=1638424748277, Client-RequestToken=b06a49491808064535b9f18840d42c50, Timestamp=1638424748280, notify=false}, requestId='null'}, retryTimes=2,errorMessage=Client not connected,current status:STARTING Dec 02 13:59:08 suninfo-omaudit startoma[10734]: 2021-12-02 13:59:08.774 ERROR 10734 --- [ restartedMain] com.alibaba.nacos.common.remote.client : Send request fail, request=ConfigQueryRequest{headers={charset=UTF-8, exConfigInfo=true, Client-AppName=unknown, Client-RequestTS=1638424748673, Client-RequestToken=ef3112bbec87f6743b5ff9da041ebcf0, Timestamp=1638424748673, notify=false}, requestId='null'}, retryTimes=0,errorMessage=Client not connected,current status:STARTING Dec 02 13:59:08 suninfo-omaudit startoma[10734]: 2021-12-02 13:59:08.875 ERROR 10734 --- [ restartedMain] com.alibaba.nacos.common.remote.client : Send request fail, request=ConfigQueryRequest{headers={charset=UTF-8, exConfigInfo=true, Client-AppName=unknown, Client-RequestTS=1638424748673, Client-RequestToken=ef3112bbec87f6743b5ff9da041ebcf0, Timestamp=1638424748673, notify=false}, requestId='null'}, retryTimes=1,errorMessage=Client not connected,current status:STARTING Dec 02 13:59:08 suninfo-omaudit startoma[10734]: 2021-12-02 13:59:08.977 ERROR 10734 --- [ restartedMain] com.alibaba.nacos.common.remote.client : Send request fail, request=ConfigQueryRequest{headers={charset=UTF-8, exConfigInfo=true, Client-AppName=unknown, Client-RequestTS=1638424748673, Client-RequestToken=ef3112bbec87f6743b5ff9da041ebcf0, Timestamp=1638424748673, notify=false}, requestId='null'}, retryTimes=2,errorMessage=Client not connected,current status:STARTING Dec 02 13:59:09 suninfo-omaudit startoma[10734]: 2021-12-02 13:59:09.078 ERROR 10734 --- [ restartedMain] com.alibaba.nacos.common.remote.client : Send request fail, request=ConfigQueryRequest{headers={charset=UTF-8, exConfigInfo=true, Client-AppName=unknown, Client-RequestTS=1638424748978, Client-RequestToken=a3b59fb4e1601aee25edf00c45fa896b, Timestamp=1638424748978, notify=false}, requestId='null'}, retryTimes=0,errorMessage=Client not connected,current status:STARTING Dec 02 13:59:09 suninfo-omaudit startoma[10734]: 2021-12-02 13:59:09.179 ERROR 10734 --- [ restartedMain] com.alibaba.nacos.common.remote.client : Send request fail, request=ConfigQueryRequest{headers={charset=UTF-8, exConfigInfo=true, Client-AppName=unknown, Client-RequestTS=1638424748978, Client-RequestToken=a3b59fb4e1601aee25edf00c45fa896b, Timestamp=1638424748978, notify=false}, requestId='null'}, retryTimes=1,errorMessage=Client not connected,current status:STARTING Dec 02 13:59:09 suninfo-omaudit startoma[10734]: 2021-12-02 13:59:09.279 ERROR 10734 --- [ restartedMain] com.alibaba.nacos.common.remote.client : Send request fail, request=ConfigQueryRequest{headers={charset=UTF-8, exConfigInfo=true, Client-AppName=unknown, Client-RequestTS=1638424748978, Client-RequestToken=a3b59fb4e1601aee25edf00c45fa896b, Timestamp=1638424748978, notify=false}, requestId='null'}, retryTimes=2,errorMessage=Client not connected,current status:STARTING Dec 02 13:59:23 suninfo-omaudit startoma[10734]: 2021-12-02 13:59:23.089 ERROR 10734 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
原提问者GitHub用户alfredodiego
我猜测是连接server响应比较慢, 实际连接操作是异步的,如果连接还没建立好就请求,会报错,然后程序就退出了。
打断点的时候因为断点延长的启动时间,所以连接上了,后续请求就都正常了。 我的环境都没有复现出这个问题。 可以试着升级一下服务端和客户端的版本,并且在启动后实际调用nacos的地方sleep1s试试看。
原回答者GitHub用户KomachiSion
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。