java - Zuul服务器运行应用程序

标签 java netflix-zuul

启动服务器时提示无法连接。我想知道为什么它试图寻找 192.168.100.16 而不是使用 localhost

我尝试使用 -Djava.net.preferIPv4Stack = true 运行应用程序,但这也不起作用。

application.yml

server:
  port: 9090

# remove that settings in production
management.security.enabled: false

eureka:
  client:
    serviceUrl:
      defaultZone: http://127.0.0.1:8761/eureka/

zuul:
  #Service will be mapped under the /api URI
  prefix: /api
#  Uncomment to disable auto-registering all services read from Eureka
#  ignoredServices: '*'
  routes:
    test:
      path: /redirect/**
      url: http://google.com
    customer-by-address:
      path: /customer-by-address/**
      url: http://localhost:9098
    customer-by-service:
      path: /customer-by-service/**
      serviceId: CUSTOMER-SERVICE
    static:
      path: /static/**

spring:
  application:
    name: zuul-server

netstat -tulpn

lesharb@LeshaRB ~ $ netstat -tulpn
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:44907         0.0.0.0:*               LISTEN      1969/java       
tcp        0      0 127.0.0.1:63342         0.0.0.0:*               LISTEN      1969/java       
tcp        0      0 0.0.0.0:49841           0.0.0.0:*               LISTEN      1969/java       
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:43927           0.0.0.0:*               LISTEN      1969/java       
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:46137         0.0.0.0:*               LISTEN      1969/java       
tcp        0      0 127.0.0.1:6942          0.0.0.0:*               LISTEN      1969/java       
tcp6       0      0 :::44811                :::*                    LISTEN      2210/java       
tcp6       0      0 :::36911                :::*                    LISTEN      3671/java       
tcp6       0      0 :::46165                :::*                    LISTEN      3671/java       
tcp6       0      0 :::41591                :::*                    LISTEN      3671/java       
tcp6       0      0 ::1:631                 :::*                    LISTEN      -               
tcp6       0      0 :::65336                :::*                    LISTEN      2210/java       
tcp6       0      0 :::9090                 :::*                    LISTEN      3671/java       
udp        0      0 0.0.0.0:38293           0.0.0.0:*                           -               
udp        0      0 127.0.1.1:53            0.0.0.0:*                           -               
udp        0      0 0.0.0.0:68              0.0.0.0:*                           -               
udp        0      0 192.168.100.12:123      0.0.0.0:*                           -               
udp        0      0 127.0.0.1:123           0.0.0.0:*                           -               
udp        0      0 0.0.0.0:123             0.0.0.0:*                           -               
udp        0      0 0.0.0.0:631             0.0.0.0:*                           -               
udp        0      0 0.0.0.0:50096           0.0.0.0:*                           -               
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           -               
udp6       0      0 fe80::3468:6113:b62:123 :::*                                -               
udp6       0      0 ::1:123                 :::*                                -               
udp6       0      0 :::123                  :::*                                -               
udp6       0      0 :::44987                :::*                                -               
udp6       0      0 :::5353                 :::*                                -   

我有这样的错误

2017-09-05 10:49:35.310  WARN 3671 --- [nfoReplicator-0] c.n.d.s.t.d.RetryableEurekaHttpClient    : Request execution failed with message: java.net.ConnectException: Connection refused (Connection refused)
2017-09-05 10:49:35.310  WARN 3671 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_ZUUL-SERVER/192.168.100.12:zuul-server:9090 - registration failed Cannot execute request on any known server

最佳答案

Zuul 正在尝试与 Eureka 通信,以获取路由请求时要使用的服务列表。但是,您的 netstat 输出没有显示任何正在监听端口 8761 的进程,而您的配置表明 Eureka 应该位于该端口。

关于java - Zuul服务器运行应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46074137/

相关文章:

java - 方法 POST 不支持 Netflix Eureka 和 ZUUL

java - 使用不等键提取器和分类器函数对列表进行分组

java - (Java使用eclipse)currentTimeMillis()

java - 安全 OAuth2 单点注销

spring - java.net.UnknownHostException Spring ,zuul, Eureka

docker - 通过Docker运行时,Eureka ZUUL “Forwarding error”

java - 对正则表达式贪婪运算符和终止字符的混淆

java - Java中的嵌套监视器

java - 让 Zuul 成为我的应用程序的唯一入口点

spring-boot - 如何使用 Eureka 在 Docker swarm 中设置服务发现