FeignClient spring boot 无法访问节点服务

问题描述

节点服务已注册到 eureka,但是当尝试从另一个微服务作为 FeignClient 访问节点服务时,它给出 java.net.UnkNownHostException

使用eureka注册节点服务eureka-js-client(https://www.npmjs.com/package/eureka-js-client)

尤里卡-helper.ts

export async function registerWithEureka(appName,PORT){
  const client = new Eureka({
    instance: {
      app: appName,hostName,ipAddr,port: {
        $: PORT,'@enabled': 'true',},vipAddress: appName,dataCenterInfo: {
        '@class': 'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo',name: 'MyOwn',eureka: {
      host: eurekaHost,port: eurekaPort,servicePath: '/eureka/apps/',maxRetries: 3,requestRetryDelay: 2000,});


server.ts

async function run() {
  const port = process.env.PORT || 4000;
  // Start up the Node server
  const server = await app();
  server.listen(port,() => {
    console.log(`Node Express server listening on http://localhost:${port}`);
  });

  registerWithEureka('pdf-generator-service-v2',port);

}

FeignClient

@FeignClient(name = PdfGeneratorClientV2.PDF_GENERATION_SERVICE_V2)
public interface PdfGeneratorClientV2 {
    String PDF_GENERATION_SERVICE_V2 = "pdf-generator-service-v2";
    @GetMapping("api/v2/pdf/job-summary")
    byte[] generatePdf(@RequestParam String jobRefId,@RequestParam String orgId,@RequestParam String workflowId);
}

eureka console

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)