Sentinel gateway 进行Dubbo 调用,设置了Route 降级,降级后返回httpstatus 为 200 ,内容为空,而不是设置的返回状态,调整多个设置都无用

6fe3ivhb  于 2022-10-19  发布在  其他
关注(0)|答案(2)|浏览(265)

Issue Description

通过 Route ID 设置了 降级后,在gatewayFilter 通过dubbo调用 鉴权服务,鉴权服务返回错误后,首次通过接口调用返回状态 500 是正常,但降级后,返回状态是 200 ,字符为空

  • filter 设置了 Mono 返回 也无效
  • 在 ErrorWebExceptionHandler 获取到了 ParamFlowException ,按照 这篇文章的 ,设置了自定义返回 Mono 也无效,依然改变了我设置的返回状态和内容
  • 未进入 BlockRequestHandler

错误信息,但拦截错误,设置了返回状态也无用:
com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowException: $D
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
|_ checkpoint ⇢ springfox.boot.starter.autoconfigure.SwaggerUiWebFluxConfiguration$CustomWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ org.springframework.web.cors.reactive.CorsWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ HTTP GET "/demo/dubbo/echo" [ExceptionHandlingWebHandler]
Stack trace:

Tell us your environment

<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-gateway</artifactId>
        <version>2.2.3.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>com.alibaba.cloud</groupId>
        <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
        <version>2.2.5.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>com.alibaba.cloud</groupId>
        <artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
        <version>2.2.5.RELEASE</version>
    </dependency>

Anything else we need to know?

如何设置,才能返回我设置的状态 和 内容?或者还有其他解决方案吗?

lb3vh1jj

lb3vh1jj1#

简单说,就是配置了限流后,如果没有进入spring boot 服务,直接gateway 返回了,就会导致 返回为空的问题

o4tp2gmn

o4tp2gmn2#

有解决方案了嘛?

相关问题