【异常】SpringCloud Gateway报错RoundRobinLoadBalancer - No servers available for service: terminal-api

这篇具有很好参考价值的文章主要介绍了【异常】SpringCloud Gateway报错RoundRobinLoadBalancer - No servers available for service: terminal-api。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

一、报错内容

2023-03-07 12:07:06.216 [gateway] [boundedElastic-9] WARN  org.springframework.cloud.loadbalancer.core.RoundRobinLoadBalancer - No servers available for service: terminal-api
org.springframework.cloud.gateway.support.NotFoundException: 503 SERVICE_UNAVAILABLE "Unable to find instance for terminal-api"
	at org.springframework.cloud.gateway.support.NotFoundException.create(NotFoundException.java:45)
	Suppressed: The stacktrace has been enhanced by Reactor, refer to additional information below: 
Error has been observed at the following site(s):
	*__checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
	*__checkpoint ⇢ cn.dev33.satoken.reactor.filter.SaReactorFilter [DefaultWebFilterChain]
	*__checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
	*__checkpoint ⇢ HTTP POST "/api/publish" [ExceptionHandlingWebHandler]
Original Stack Trace:
		at org.springframework.cloud.gateway.support.NotFoundException.create(NotFoundException.java:45)
		at org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClientFilter.lambda$filter$2(ReactiveLoadBalancerClientFilter.java:124)
		at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:185)
		at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120)
		at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82)
		at reactor.core.publisher.FluxDematerialize$DematerializeSubscriber.onNext(FluxDematerialize.java:98)
		at reactor.core.publisher.FluxDematerialize$DematerializeSubscriber.onNext(FluxDematerialize.java:44)
		at reactor.core.publisher.FluxFlattenIterable$FlattenIterableSubscriber.drainAsync(FluxFlattenIterable.java:421)
		at reactor.core.publisher.FluxFlattenIterable$FlattenIterableSubscriber.drain(FluxFlattenIterable.java:686)
		at reactor.core.publisher.FluxFlattenIterable$FlattenIterableSubscriber.onNext(FluxFlattenIterable.java:250)
		at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:74)
		at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816)
		at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:249)
		at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.complete(MonoIgnoreThen.java:292)
		at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onNext(MonoIgnoreThen.java:187)
		at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:236)
		at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onComplete(MonoIgnoreThen.java:203)
		at reactor.core.publisher.MonoIgnoreElements$IgnoreElementsSubscriber.onComplete(MonoIgnoreElements.java:89)
		at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:260)
		at reactor.core.publisher.FluxDematerialize$DematerializeSubscriber.onComplete(FluxDematerialize.java:121)
		at reactor.core.publisher.FluxDematerialize$DematerializeSubscriber.onNext(FluxDematerialize.java:91)
		at reactor.core.publisher.FluxDematerialize$DematerializeSubscriber.onNext(FluxDematerialize.java:44)
		at reactor.core.publisher.FluxIterable$IterableSubscription.fastPath(FluxIterable.java:340)
		at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:227)
		at reactor.core.publisher.FluxDematerialize$DematerializeSubscriber.request(FluxDematerialize.java:127)
		at reactor.core.publisher.FluxPeek$PeekSubscriber.request(FluxPeek.java:138)
		at reactor.core.publisher.MonoIgnoreElements$IgnoreElementsSubscriber.onSubscribe(MonoIgnoreElements.java:72)
		at reactor.core.publisher.FluxPeek$PeekSubscriber.onSubscribe(FluxPeek.java:171)
		at reactor.core.publisher.FluxDematerialize$DematerializeSubscriber.onSubscribe(FluxDematerialize.java:77)
		at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:165)
		at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:87)
		at reactor.core.publisher.Mono.subscribe(Mono.java:4400)
		at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:263)
		at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51)
		at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:157)
		at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816)
		at reactor.core.publisher.MonoCollectList$MonoCollectListSubscriber.onComplete(MonoCollectList.java:128)
		at reactor.core.publisher.DrainUtils.postCompleteDrain(DrainUtils.java:132)
		at reactor.core.publisher.DrainUtils.postComplete(DrainUtils.java:187)
		at reactor.core.publisher.FluxMaterialize$MaterializeSubscriber.onComplete(FluxMaterialize.java:141)
		at reactor.core.publisher.FluxTake$TakeSubscriber.onComplete(FluxTake.java:153)
		at reactor.core.publisher.FluxTake$TakeSubscriber.onNext(FluxTake.java:133)
		at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)
		at reactor.core.publisher.SerializedSubscriber.onNext(SerializedSubscriber.java:99)
		at reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.onNext(FluxTimeout.java:180)
		at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816)
		at reactor.core.publisher.MonoCollectList$MonoCollectListSubscriber.onComplete(MonoCollectList.java:128)
		at org.springframework.cloud.commons.publisher.FluxFirstNonEmptyEmitting$FirstNonEmptyEmittingSubscriber.onComplete(FluxFirstNonEmptyEmitting.java:325)
		at reactor.core.publisher.FluxSubscribeOn$SubscribeOnSubscriber.onComplete(FluxSubscribeOn.java:166)
		at reactor.core.publisher.Operators.complete(Operators.java:137)
		at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:148)
		at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:87)
		at reactor.core.publisher.Flux.subscribe(Flux.java:8469)
		at reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:200)
		at reactor.core.publisher.MonoFlatMapMany.subscribeOrReturn(MonoFlatMapMany.java:49)
		at reactor.core.publisher.Flux.subscribe(Flux.java:8455)
		at reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:200)
		at reactor.core.publisher.MonoFlatMapMany.subscribeOrReturn(MonoFlatMapMany.java:49)
		at reactor.core.publisher.FluxFromMonoOperator.subscribe(FluxFromMonoOperator.java:76)
		at reactor.core.publisher.FluxSubscribeOn$SubscribeOnSubscriber.run(FluxSubscribeOn.java:194)
		at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:84)
		at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:37)
		at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
		at java.util.concurrent.FutureTask.run(FutureTask.java)
		at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
		at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
		at java.lang.Thread.run(Thread.java:745)
2023-03-07 12:07:06.236 [gateway] [boundedElastic-9] ERROR chandler.GatewayExceptionHandler - [网关异常处理]请求路径:/api/publish,异常信息:503 SERVICE_UNAVAILABLE "Unable to find instance for terminal-api"

类似报错如下

Load balancer does not contain an instance for the service upms-admin
No servers available for service: joolun-upms-admin

feign 服务间调用异常
feign.FeignException$ServiceUnavailable: [503] during [POST] to [http://upms-admin/loglogin/save] [FeignLogLoginService#saveLogLogin(SysLogLogin,String)]: [Load balancer does not contain an instance for the service joolun-upms-admin]
	at feign.FeignException.serverErrorStatus(FeignException.java:237)
	at feign.FeignException.errorStatus(FeignException.java:180)
	at feign.FeignException.errorStatus(FeignException.java:169)
	at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:92)

类似报错如下

 [503] during [POST] to  [Load balancer does not contain an instance for the service 
{
    "code": 1,
    "msg": "[503] during [POST] to [http://xxx-thirdparty-api/user/selectHrEmpByHrEmp] [FeignHrEmpService#selectHrEmpByHrEmp(HrEmp,String)]: [Load balancer does not contain an instance for the service joolun-thirdparty-api]",
    "data": null,
    "ok": false
}

# 二、报错说明
## 2.1、系统架构说明
terminal-api是一个微服务的子工程,所有请求都经过SpringCloud Gateway。

## 2.2、系统架构图
SpringCloud Gateway对请求进行转发
请求URL包含/api/publish ,已经在拦截器中,直接放行了的。
放行的逻辑如下内容所示:

```java
@Component
@Slf4j
public class ValidateSignFilter extends AbstractGatewayFilterFactory<ValidateSignFilter.Config> {
    private final static String[] VALIDATE_URL = new String[]{"/api/publish"};
    public ValidateSignFilter() {
        super(ValidateSignFilter.Config.class);
    }
    @Override
    public String name() {
        return "ValidateSignFilter";
    }
    @Getter
    @Setter
    static class Config {
        private Integer order;
    }
    @Override
    public GatewayFilter apply(ValidateSignFilter.Config config) {
        return (exchange, chain) -> {
            ServerHttpRequest request = exchange.getRequest();
            if (StringUtils.containsAnyIgnoreCase(request.getURI().getPath(), VALIDATE_URL)) {
                return chain.filter(exchange);
            } 
            //主线校验略
        };
    }
}


引起这个问题的原因有很多, 简要归纳一下:

1.服务名称不能有中划线

2.本地IP地址使用了虚拟网卡地址

3.正常启用了子服务

三、报错解决

3.1 解决方案1

最后排查,因为没有启动有效的terminal-api服务,所以出现了上面的报错。
重新启动terminal-api 即可。

3.2 解决方案2:

虽然在Nacos中看到虽然健康实例,但是其实TA是已经挂了的。

详细看我的文章:Nacos的双写机制。

这个时候,只能从K8s部署微服务的层面,去重启节点了。文章来源地址https://www.toymoban.com/news/detail-623680.html

到了这里,关于【异常】SpringCloud Gateway报错RoundRobinLoadBalancer - No servers available for service: terminal-api的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【IO异常】HTTP请求报错Error writing to server

    报错信息如下: [2023-01-04 13:36:02.185]-ERROR-[biz:aplus-task-oms1060189862335877121][sys:aplus-cms-tran1060189866052390912][com.phfund.aplus.cms.tran.module.counter.service.impl.OcrServiceImpl-102][调用远程服务发送文件异常:] cn.hutool.http.HttpException: Error writing to server at cn.hutool.http.HttpResponse.init(HttpResponse.java:423) a

    2024年01月15日
    浏览(43)
  • qt安装报错:下载“http://download.qt.io/online/xxxxx/_meta.7z“server replied: Bad Gateway出现网络错误

    直接双击官网上下载下来的qt安装包,然后注册登录后到了第三步【安装程序】时,进行远程检索文件总会卡在这里,无法进行到下一步。报错如下: 解决办法: 点击右上角的叉号,关闭当前的安装程序,然后从cmd里启动该安装包,并为其 切换中科大的源 打开cmd 将路径切换

    2024年02月11日
    浏览(42)
  • 【异常】客户端发起HTTPS请求报错,服务端返回400 Bad Request ,并且提示No required SSL certificate was sent

    HTTP响应码400表示客户端发送了一个无效的请求。这可能是由于请求中缺少必需的参数或格式不正确等原因导致的。服务器无法处理此请求并返回400响应码。如果您正在编写Web应用程序,建议在处理请求时检查请求的有效性,并在必要时返回400响应码以指示客户端请求无效。

    2024年02月11日
    浏览(49)
  • 【SpringCloud】SpringCloud Gateway详解

    微服务分为多个服务,有很多服务是内部人员要用的,但是现在谁都可以访问到,那我们该怎么办呢? Spring Cloud最新面试题 Spring Cloud Nacos详解之注册中心 Spring Cloud Nacos详解之配置中心 Spring Cloud Nacos详解之集群配置 Spring Cloud Eureka详解 Spring Cloud Frign详解 Spring Cloud Ribbon详解

    2024年02月12日
    浏览(37)
  • mysql - 解决使用mysqld运行时出现报错:[ERROR] [MY-010119] [Server] Aborting(mysqld启动异常抛出错误,详细解决方法)

    当使用mysqld运行时出现异常报错信息:[ERROR] [MY-010119] [Server] Aborting,查看 mysqld.local.err 文件时没有其他任何额外信息,本教程提供解决办法。 只要是错误和我一样就可以搞定。 首先,

    2024年02月19日
    浏览(46)
  • 【异常解决】(二)解决docker报错Error response from daemon: Get... http: server gave HTTP response to HTTPS

    场景:本机个人电脑Windows系统安装了docker客户端,远程Linux服务器部署了镜像仓库,远程仓库可以接收别的服务器的镜像推送,但接收本机电脑镜像时失败(实际为推送失败)。使用docker login XXXX:XX:XX:XX:8081命令登录时,报错 Error response from daemon: Get “https://XXXX:XX:XX:XX:8081/v2

    2024年02月11日
    浏览(65)
  • nacos启动报错Nacos Server did not start because dumpservice bean construction failure :No DataSource set

    刚开始看到这个错误还是挺蒙的,nacos启动居然还能报错,仔细一看报错说的数据源问题,才想起来是之前设置了nacos配置中心持久化的问题,使用nacos配置中心持久化我们会在nacos配置文件中指定持久化数据源,因此如果你的持久化数据源nacos连接不到,nacos就会报错 解决方案

    2024年02月11日
    浏览(38)
  • SpringCloud网关Gateway认证鉴权【SpringCloud系列7】

    SpringCloud 大型系列课程正在制作中,欢迎大家关注与提意见。 程序员每天的CV 与 板砖,也要知其所以然,本系列课程可以帮助初学者学习 SpringBooot 项目开发 与 SpringCloud 微服务系列项目开发 本文章是系列文章中的一篇 1、SpringCloud 项目基础工程搭建 【SpringCloud系列1】 2、S

    2024年02月09日
    浏览(46)
  • kubectl命令报错:Unable to connect to the server: dial tcp XXX:16443: connect: no route to host

    前提 架构: keepalived+haproxy+kubernetes 问题说明 kubernetes集群好久不用了,今天打开集群执行一个 kubectl get nodes 命令,报错如下: Unable to connect to the server: dial tcp 192.168.2.XXX:16443: connect: no route to host 分析原因 出现这个问题几种原因, 集群坏了:如果报错的IP是master1的节点IP或虚

    2024年02月09日
    浏览(124)
  • 【SpringCloud-5】gateway网关

    网关是干啥用的就不用再说了。 sringcloud中的网关,第一代是zuul,但是性能比较差(1.x是阻塞式的,2.x是基于Netty的),然后有了第二代GateWay,基于Reactor模型 异步非阻塞。  springcloud网关就是一系列的filter,在请求到达真实服务的前后,进行拦截处理。   GateWay 核⼼逻辑:路

    2024年02月09日
    浏览(36)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包