spring cloud consul 健康检查Value must not be null

spring cloud consul 在注册时 健康检查状态一直是down
docker 启动consul 命令如下
docker run -d —name server1 -h server1 consul agent -server -bootstrap-expect 3
docker run -d —name server2 -h server2 consul agent -server -join 172.17.0.2
docker run -d —name server3 -h server3 consul agent -server -join 172.17.0.2
docker run -d -p 8400:8400 -p 8500:8500 -p 8600:53/udp -h client1 consul agent -join 172.17.0.2 -ui -client=0.0.0.0
启动后:
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                                                                                    NAMES
e49dfa826d53 consul "docker-entrypoint..." 26 minutes ago Up 26 minutes 0.0.0.0:8400->8400/tcp, 8300-8302/tcp, 8301-8302/udp, 8600/tcp, 8600/udp, 0.0.0.0:8500->8500/tcp, 0.0.0.0:8600->53/udp affectionate_galileo
7e3bdf747a3b consul "docker-entrypoint..." 34 minutes ago Up 34 minutes 8300-8302/tcp, 8500/tcp, 8301-8302/udp, 8600/tcp, 8600/udp server3
2a356d3138bc consul "docker-entrypoint..." 34 minutes ago Up 34 minutes 8300-8302/tcp, 8500/tcp, 8301-8302/udp, 8600/tcp, 8600/udp server2
0045c232dd86 consul "docker-entrypoint..." 36 minutes ago Up 36 minutes 8300-8302/tcp, 8500/tcp, 8301-8302/udp, 8600/tcp, 8600/udp server1
application配置文件如下:
spring:
cloud:
consul:
host: localhost
port: 8500
discovery:
health-check-interval: 15s
health-check-url: http://192.168.0.142:${server.port}/health
application:
name: consul-disconvery
server:
port: 9002

management:
security:
enabled: false
启动后健康检查报错如下:
{"status":"DOWN","discoveryComposite":{"description":"Spring Cloud Consul Discovery Client","status":"UP","discoveryClient":{"description":"Spring Cloud Consul Discovery Client","status":"UP","services":["consul","consul-disconvery"]}},"diskSpace":{"status":"UP","total":250685575168,"free":207947386880,"threshold":10485760},"refreshScope":{"status":"UP"},"hystrix":{"status":"UP"},"consul":{"status":"DOWN","services":{"consul":[],"consul-disconvery":[]},"error":"java.lang.IllegalArgumentException: Value must not be null"}}
跟踪consul健康检查代码:
public class ConsulHealthIndicator extends AbstractHealthIndicator {

private ConsulClient consul;

public ConsulHealthIndicator(ConsulClient consul) {
this.consul = consul;
}

@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
try {
Response<Self> self = consul.getAgentSelf();
Config config = self.getValue().getConfig();
Response<Map<String, List<String>>> services = consul
.getCatalogServices(QueryParams.DEFAULT);
builder.up()
.withDetail("services", services.getValue())
.withDetail("advertiseAddress", config.getAdvertiseAddress()) //获取到为null所以报错
.withDetail("datacenter", config.getDatacenter())
.withDetail("domain", config.getDomain())
.withDetail("nodeName", config.getNodeName())
.withDetail("bindAddress", config.getBindAddress())
.withDetail("clientAddress", config.getClientAddress());
}
catch (Exception e) {
builder.down(e);
}
}
}
请问怎么解决。。。是配置的问题还是docker 启动consul的问题,请各位帮忙看看
 
 
 
已邀请:

yking

赞同来自:

consul版本低一点就可以了,原因还没有找到,参考的:http://blog.csdn.net/michael_h ... 02897

要回复问题请先登录注册