spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

StripPrefixGatewayFilter 404

Open yydzxz opened this issue 1 year ago • 5 comments

Manifest-Version: 1.0 Implementation-Title: Spring Cloud Gateway Core Implementation-Version: 2.1.3.RELEASE Built-By: jenkins Implementation-Vendor-Id: org.springframework.cloud Created-By: Apache Maven 3.5.0 Build-Jdk: 1.8.0_201 Implementation-URL: https://spring.io/spring-cloud/spring-cloud-gatewa y/spring-cloud-gateway-core Implementation-Vendor: Pivotal Software, Inc.

I am currently encountering a 404 issue, and I haven't found any relevant information in the issues or on Stack Overflow. I would like to know if this problem has been fixed in the latest version. If it has been fixed, please provide the resolution method. Thank you very much. (Due to the involvement of too many services, upgrading the gateway version is currently not possible.)

To troubleshoot the issue, I added some logs in the source code. Below is the source code with the added logs. image

The 2nd, 4th, and 6th lines in the log are all related to the route "saas-mini-application." From the log, it can be observed that in the 2nd line, the args are {parts=2}, but in the 4th line, the configuration is 3. However, from the code, it can be seen that the value of configuration comes from the args. This bug is not consistently reproducible and occurs with a very low probability. Therefore, I suspect it might be a concurrency issue. From the log, it can be seen that at this moment, there is another log entry for a different route, "saas-order-third-platform," and for this route, parts=3. image

yydzxz avatar Jan 13 '24 03:01 yydzxz

where is the 404?

kimmking avatar Jan 15 '24 00:01 kimmking

where is the 404?

saas-order-platform, /api/order/platform/**, StripPrefix=3,

Under normal circumstances, when calling the URL http://gateway/api/order/thirdplatform/a/b, the request is directed to the path /a/b of the saas-order-platform service.

However, in some situations, the StripPrefix value has inexplicably changed to 2. In this case, when calling the URL http://gateway/api/order/thirdplatform/a/b, the request is directed to the path /thirdplatform/a/b of the saas-order-platform service, resulting in a 404 error.

yydzxz avatar Jan 15 '24 02:01 yydzxz

image image

args is 3, but config.getParts() is 2

yydzxz avatar Jan 16 '24 06:01 yydzxz

Is there an official solution to this problem? We also encountered it. In cases of high concurrency, there may be routing path errors and StripPrefix={2} not taking effect.

mylxf avatar Jan 25 '24 02:01 mylxf

image image

bug code is line 177

yydzxz avatar Jan 25 '24 07:01 yydzxz

In the future, please refrain from sharing text via images.

If you'd like us to spend some time investigating, please take the time to provide a complete, minimal, verifiable sample (something that we can unzip attached to this issue or git clone, build, and deploy) that reproduces the problem.

spencergibb avatar Mar 11 '24 21:03 spencergibb

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues avatar Mar 18 '24 21:03 spring-cloud-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

spring-cloud-issues avatar Mar 25 '24 21:03 spring-cloud-issues

image image bug code is line 177

May I ask which version has fixed this issue? I also encountered the same problem

forgetmetoo avatar Aug 13 '24 08:08 forgetmetoo