Skip to content

Return 503 for unavailable downstream service#4230

Open
king-407 wants to merge 1 commit into
spring-cloud:mainfrom
king-407:issue-4208-unavailable-downstream-503
Open

Return 503 for unavailable downstream service#4230
king-407 wants to merge 1 commit into
spring-cloud:mainfrom
king-407:issue-4208-unavailable-downstream-503

Conversation

@king-407

Copy link
Copy Markdown

Fixes #4208.

This updates the WebFlux NettyRoutingFilter so downstream connection failures are reported as 503 Service Unavailable instead of 500 Internal Server Error.

Previously, when Gateway could not connect to the downstream service, for example because the target port was closed, Reactor Netty raised a connection exception and the request resulted in a generic 500 response.

The change maps connection-related failures such as ConnectException and UnknownHostException to ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE).

Validation:

  • ./mvnw -pl spring-cloud-gateway-server-webflux -Dtest=NettyRoutingFilterIntegrationTests#shouldApplyConnectTimeoutPerRoute test
  • ./mvnw -pl spring-cloud-gateway-server-webflux -Dtest=NettyRoutingFilterIntegrationTests test
  • git diff --check

Signed-off-by: king-407 <95581750+king-407@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unavailable downstream service results in HTTP 500

2 participants