spring-cloud-alibaba版本升级 服务报错 Server check fail, please check server xxxxx ,port xxx is available

背景

最近要将项目中的spring cloud Alibaba 组件进行升级。由2.2.6.RELEASE 升级到2.2.8.RELEASE。然后服务启动报错。报错信息如下:
spring-cloud-alibaba版本升级 服务报错 Server check fail, please check server xxxxx ,port xxx is available_第1张图片

分析

看了一下报错的地方,发现是连接nacos 失败。看日志发现了一个问题,我的nacos 端口是18848 结果报错信息是19848!配置翻了一遍没有看到有配置19848的。没办法,只能去nacos官网找答案。

解决

进入nacos文档,看到有个兼容性及使用的菜单,点进去看了一下,
spring-cloud-alibaba版本升级 服务报错 Server check fail, please check server xxxxx ,port xxx is available_第2张图片
原来是Nacos2.0版本相比1.X新增了gRPC的通信方式,因此需要增加2个端口。新增端口是在配置的主端口(server.port)基础上,进行一定偏移量自动生成。这下明白了19848 端口是怎么来的的。
在nacos 文档上 有个兼容性明确告知 请勿使用2.0以上版本客户端连接Nacos1.X服务端。
spring-cloud-alibaba版本升级 服务报错 Server check fail, please check server xxxxx ,port xxx is available_第3张图片
然后我在spring cloud Alibaba 官网上查找依赖版本说明。发现2.2.6 使用的nacos 版本是1.4.2 而 2.2.8 使用的是2.1.0 。那么出现错误的原因找到了,解决就简单了。
spring-cloud-alibaba版本升级 服务报错 Server check fail, please check server xxxxx ,port xxx is available_第4张图片

因为后续nacos 要升级到2.0 版本 所以在父工程中需要的spring cloud Alibaba 排除nacos-client ,引入1.4.2 版本的nacos-client 即可。

 			<dependency>
                <groupId>com.alibaba.cloudgroupId>
                <artifactId>spring-cloud-alibaba-dependenciesartifactId>
                <version>${spring-cloud-alibaba.version}version>
                <type>pomtype>
                <scope>importscope>
                <exclusions>

                    <exclusion>
                        <groupId>io.seatagroupId>
                        <artifactId>seata-spring-boot-starterartifactId>
                    exclusion>
                    
                    <exclusion>
                        <groupId>com.alibaba.nacosgroupId>
                        <artifactId>nacos-clientartifactId>
                    exclusion>
                exclusions>
            dependency>
            <dependency>
                <groupId>com.alibaba.nacosgroupId>
                <artifactId>nacos-clientartifactId>
                <version>${nacos-client.version}version>
            dependency>
            <dependency>
                <groupId>io.seatagroupId>
                <artifactId>seata-spring-boot-starterartifactId>
                <version>${seata.version}version>
            dependency>

参考资料:

nacos官网
spring cloud Alibaba 版本说明

你可能感兴趣的:(nacos,java,spring,cloud,微服务)