【问题标题】:Eureka Client Service not reachable on PCF Dev在 PCF Dev 上无法访问 Eureka 客户端服务
【发布时间】:2018-10-20 16:29:15
【问题描述】:

这是我使用 PCF Dev 的第一个微服务。我已经创建了以下 Eureka Server App。

@EnableEurekaServer
@SpringBootApplication
public class EurekaServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaServiceApplication.class, args);
    }
}

以下是 eureka-server 服务的属性

eureka-service.register-with-eureka=false
eureka-service.fetch-registry=false
eureka-service.defaultZone=http://eureka-service.local.pcfdev.io/
eureka-service.logging.level.com.netflix.eureka=OFF
eureka-service.logging.level.com.netflix.discovery=OFF

下面是eureka-client服务

@EnableDiscoveryClient
@SpringBootApplication
public class EurekaClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaClientApplication.class, args);
    }
}

@RestController
class ServiceInstanceRestController {

    @Autowired
    private DiscoveryClient discoveryClient;

    @RequestMapping("/service-instances/{applicationName}")
    public List<ServiceInstance> serviceInstancesByApplicationName(@PathVariable String applicationName) {
        return this.discoveryClient.getInstances(applicationName);
    }
}

以下是 eureka-client 服务的属性

eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.client.defaultZone=http://eureka-client.local.pcfdev.io/
eureka.client.logging.level.com.netflix.eureka=ON
eureka.client.logging.level.com.netflix.discovery=ON

我已经在本地运行的 PCF Dev 实例上部署了微服务

当我在本地将服务器和客户端作为 Java 应用程序运行时,我可以看到来自 service-instances/eureka-client 端点的响应。但是当我尝试调用以下端点时,我得到一个空数组

http://eureka-client.local.pcfdev.io/service-instances/eureka-client

当我尝试使用 URL 访问 eureka-service 时

http://eureka-service.local.pcfdev.io/

我收到以下回复:

This site can’t be reached eureka-service.local.pcfdev.io refused to connect.
Search Google for eureka service local pcfdev io
ERR_CONNECTION_REFUSED

提前致谢。

Edit-1:

根据@Barath 的评论,我修改了客户端应用程序的 application.properties 文件,如下所示,但问题仍未解决。之前,我在 application.properties 文件中错误地引用了客户端应用程序名称。

eureka-client.register-with-eureka=true
eureka-client.fetch-registry=true
eureka-client.serviceUrl.defaultZone=http://eureka-client.local.pcfdev.io/
eureka-client.logging.level.com.netflix.eureka=ON
eureka-client.logging.level.com.netflix.discovery=ON

客户端的 bootstrap.properties 文件有以下条目:

spring.application.name=eureka-client 

服务器的 bootstrap.properties 文件有以下条目:

spring.application.name=eureka-service

Edit-2

服务器:https://github.com/abnig/eureka-service 客户:https://github.com/abnig/eureka-client

【问题讨论】:

  • 属性应该是eureka.client.serviceUrl.defaultZone
  • 任何代码路径?
  • eureka 服务器详细信息不正确。定义这两个属性eureka.instance.hostname=eureka-service.local.pcfdev.io eureka.client.register-with-eureka=false
  • FYR cloud-native。查看要设置的属性的 pcf 配置文件

标签: netflix-eureka pcf


【解决方案1】:

在eureka server 和client 中定义的属性描述如下

尤里卡服务器

eureka:
  instance:
    hostname: eureka-service.local.pcfdev.io
  client:
    fetch-registry: false
    register-with-eureka: false

尤里卡客户端

eureka:
  client:
    serviceUrl:
      defaultZone: https://eureka-service.local.pcfdev.io/eureka
    register-with-eureka: true
    fetch-registry: true

请参考spring-cloud-native

【讨论】:

  • 现在我可以获取服务实例了。但是当我点击 URL eureka-service.local.pcfdev.io/eureka 时,我仍然收到 ERR_CONNECTION_REFUSED 错误,就像我的问题一样。感谢您的信息。
  • 当您在浏览器中尝试时,不要包含 /eureka,它是仅适用于客户端的默认路径。
  • 即使eureka-service.local.pcfdev.io 给了我同样的错误。我看到我的主机已经有如下条目,一定是 PCF Dev 添加的:127.0.0.1 eureka-service.local.pcfdev.io
猜你喜欢
  • 2018-02-18
  • 2020-05-22
  • 2018-10-11
  • 1970-01-01
  • 1970-01-01
  • 2013-12-27
  • 2021-01-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多