Zuul无法使用动态端口微服务进行路由

时间:2018-11-13 11:27:20

标签: java spring-boot microservices netflix-eureka netflix-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
  

Eureka服务器application.yml

server:
  port: 8761

eureka:
  client:
    register-with-eureka: false
    fetch-registry: false
  

随启动,Sring云版本是动态的(${spring-cloud.version})   2.1.0。发布。

0 个答案:

没有答案