java - Zuul 无法使用动态端口微服务进行路由
问题描述
我有一个带有动态端口的微服务,即server.port=0
. 微服务在 eureka 上得到了很好的注册,它已经启动并运行了。
但是,当我尝试通过 Zuul 网关访问它时,它无法处理我的 zuul 网关中的以下日志。
c.netflix.loadbalancer.BaseLoadBalancer : Client: book instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=book,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null
c.n.l.DynamicServerListLoadBalancer : Using serverListUpdater PollingServerListUpdater
c.netflix.config.ChainedDynamicProperty : Flipping property: book.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
c.n.l.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client book initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=book,current list of Servers=[192.168.60.1:0],Load balancer stats=Zone stats: {defaultzone=[Zone:defaultzone; Instance count:1; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;]
},Server stats: [[Server:192.168.60.1:0; Zone:defaultZone; Total Requests:0; Successive connection failure:0; Total blackout seconds:0; Last connection made:Thu Jan 01 05:30:00 IST 1970; First connection made: Thu Jan 01 05:30:00 IST 1970; Active Connections:0; total failure count in last (1000) msecs:0; average resp time:0.0; 90 percentile resp time:0.0; 95 percentile resp time:0.0; min resp time:0.0; max resp time:0.0; stddev resp time:0.0]
]}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@4dbc2e52
但是,当我将微服务 ( book
) 的端口更改为非动态端口时server.port = 8081
,一切都运行良好,并且每次我也必须重新启动 zuul 应用程序。我猜当其中一个微服务更改端口时,它并不顺利。
让我分享application.yml
两个文件的内容。
微服务(书),
application.yml
spring:
application:
name: book
server:
port: 0 # I change it between 0 and 8081 (8081 works like a charm)
eureka:
client:
service-url:
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
instance:
prefer-ip-address: true
祖尔
application.yml
server:
port: 8080
spring:
application:
name: gatekeeper
zuul:
routes:
book:
serviceId: book
#Added it so as to increase the timeout for the underlying hysterix of the zuul
hystrix:
command:
default:
execution:
isolation:
strategy: THREAD
thread:
timeoutInMilliseconds: 60000
尤里卡服务器
application.yml
server:
port: 8761
eureka:
client:
register-with-eureka: false
fetch-registry: false
Sring 云版本是动态的 (
${spring-cloud.version}
) 启动 2.1.0.release。
解决方案
推荐阅读
- php - 使用 Ajax 和 Laravel 控制器从 datepicker 获取日期
- java - 将 HOCON 字符串转换为 Java 对象
- python - 在matplotlib中获取鼠标点击的坐标 - Python
- ms-access - 如何在失控的表格中停止自动编号?
- javascript - Redux Form 通过简单的验证返回意外错误。为什么?
- javascript - 在随后的几个月中复制条目
- c++ - 在 pe 二进制 rdata 部分(字符串)中对本地源文件的引用
- ruby-on-rails - 路由错误没有路由匹配 [POST] "/user/register"
- dask - Dask Workers 终身选项不等待工作完成
- python - 将行转换为带有串行数据的 pandas 数据框中的列