【问题标题】:Spring consul turbine error - Could not initiate connection to host, giving up: []Spring consul 涡轮错误 - 无法启动与主机的连接,放弃:[]
【发布时间】:2016-12-01 10:36:11
【问题描述】:

我想从我的涡轮应用程序中读取在 consul 注册的服务。我为此配置了涡轮机:

Bootstrap.yml

 server:
 port: 8050

spring:
 cloud:
  consul:
   discovery:
  prefer-ip-address: true
 host: *****hostName where consul reside****
 port: 8500

turbine:
 aggregator:
   clusterConfig: dm-geo
 appConfig: dm-geo

有依赖关系-

 <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
 </dependency>

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-netflix-turbine</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>

在主应用程序类 -

  @EnableTurbine
  @EnableHystrixDashboard
  @EnableDiscoveryClient

所有这些配置都是在涡轮应用上完成的。

现在在 consul 上注册的每个服务都有依赖关系 -

    <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-hystrix</artifactId>
    </dependency>

    <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-consul-discovery</artifactId>
   </dependency>

@EnableHystrix @EnableDiscoveryClient 在带有HystrixCommand 的应用程序类上,我们使用适当的回退逻辑调用其他服务的方法。

application.properties:-

  spring.application.name=dm-geo

现在我们的 python 脚本需要配置发现这些服务并在 consul 上注册。 当我尝试获取每个 hystrix.stream 时,我可以为此获取 hystrix 仪表板。

但从我的涡轮机应用程序中,错误记录为

"timestamp":"2016-07-27T17:33:14.406+05:30","message":"Could not initiate connection to host, giving up,"logger_name":"com netflix turbine monitor instance InstanceMonitor","thread_name":"InstanceMonitor"

有人可以在这方面提供帮助吗???

【问题讨论】:

  • spring.application.name 需要进入 bootstrap.properties,你试过了吗?
  • 是的,今天我在做这个。现在已经解决了。至于我们的应用程序turbine.stream 是一个经过身份验证的URL,所以我必须跳过它,然后它可以完美地显示涡轮流和仪表板。作为 security.ignored = URL 路径。

标签: java spring-cloud consul hystrix turbine


【解决方案1】:

现在我们的应用涡轮机已经解决了。基本上,流是通过 URL 进行身份验证的,所以我必须跳过这个,然后完美地显示涡轮流和仪表板。例如:

security.ignored = /turbine.stream

在 Spring Boot 应用程序中。

【讨论】:

    猜你喜欢
    • 2019-06-12
    • 2019-01-07
    • 2015-10-22
    • 2011-03-22
    • 2023-03-05
    • 2022-06-16
    • 1970-01-01
    • 1970-01-01
    • 2015-09-16
    相关资源
    最近更新 更多