Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Will different requests of the microservice IP fail when using Spring Cloud Gateway

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "whether different requests for IP will fail when using Spring Cloud Gateway". The explanation in this article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn whether different requests for IP when using Spring Cloud Gateway will fail.

The background of the problem

In the process of using Spring Cloud Gateway, you want to configure multi-Routes to map different micro-services, because the access paths of Gateway and Zuul are different (zuul will have service service Id), resulting in an error.

Phenomenal expression

Problem positioning

It is considered to be a problem with configuring Predicate.

Routes:-id: after_route uri: lb://user-center predicates: # when the current time is after the set time To access # otherwise you will get error #-After=2010-01-01T18:00:00.789-07:00 [America/Denver] # when Host belongs to * * .geekplus.com.cn or * * .life-runner.com # http://localhost:9999/**-> user-center/** # eg. Http://localhost:9999/users/1-> user-center/users/1 #-Host=**.geekplus.com.cn,**.life-runner.com-TimeBetween= 6:00, 11:00-Path=/users/** filters:-AddRequestHeader=CompanyKey,123456-AddResponseHeader=Success,Isaac-PreLog=CustomLogKey CustomLogValue-id: content_route uri: lb://shared-center-After=2010-01-01T18:00:00.789-07:00 [America/Denver]-Path=/share/** filters:-AddRequestHeader=CompanyKey,123456-AddResponseHeader=Success,Isaac-PreLog=CustomLogKey,CustomLogValue

Think of it as a matter of order.

Routes:-id: content_route uri: lb://shared-center predicates:-Path=/share/**-id: after_route uri: lb://user-center predicates: # access-TimeBetween= at 6:00 when the current time is later than the set time 11:00-Path=/users/** filters:-AddRequestHeader=CompanyKey,123456-AddResponseHeader=Success,Isaac-PreLog=CustomLogKey,CustomLogValue

I thought I wrote it wrong. Ask for help everywhere, but there is really little information about Gateway on the Internet. Or stand on your own feet, according to the error message, look at the metadata in Nacos and find anomalies!

Problem conclusion

Both gateway and user-center have been restarted, because the service Ip has changed after the restart, and the two ip are the same in the service registry, so they can be accessed. The ip registered in the Discovery Center is the old Ip, which is different from the IP of gateway/user-center, which causes the request to fail. The details are as follows: shared-center: 172.16.33.167 user-center & gateway: 172.16.29.0

The solution is to restart shared-center and get the instance Ip again, and the result will return to normal!

Tips > I use Spring Cloud Alibaba Nacos as the service discovery center. After restarting the content service, I found that the failed IPservice in the center has not been refreshed and needs to be dealt with manually, otherwise the old IP will still be called. Thank you for your reading. The above is the content of "whether different requests for IP will fail when using Spring Cloud Gateway". After the study of this article, I believe you will have a deeper understanding of whether different requests for IP when using Spring Cloud Gateway will fail, and the specific usage needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report