记一次apollo连接失败处理

服务器:centos7
apollo:1.7
开发环境:springboot2.3
1.整合

<dependency>
    <groupId>com.ctrip.framework.apollo</groupId>
    <artifactId>apollo-client</artifactId>
    <version>1.7.0</version>
</dependency>
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.10</version>
</dependency>
app.id=dev
apollo.meta=http://192.167.2.123:8080 #eureka地址
apollo.bootstrap.enable=true
apollo.bootstrap.namespaces=application
@SpringBootApplication
@EnableApolloConfig
public class ApolloServerApplication {
}

2.启动时异常

Load config failed, will retry in 1 SECONDS. appId: dev, cluster: default, namespaces: application
2021-02-01 19:02:30.617  WARN 42252 --- [           main] c.c.f.a.i.AbstractConfigRepository       : Sync config failed, will retry. Repository class com.ctrip.framework.apollo.internals.RemoteConfigRepository, reason: Load Apollo Config failed - appId: dev, cluster: default, namespace: application, url: http://192.168.1.26:8080/configs/dev/default/application?ip=192.168.1.2 [Cause: Could not complete get operation [Cause: connect timed out]]
2021-02-01 19:02:31.623  WARN 42252 --- [           main] c.c.f.a.i.RemoteConfigRepository         : Load config failed, will retry in 1 SECONDS. appId: dev, cluster: default, namespaces: application
2021-02-01 19:02:33.624  WARN 42252 --- [           main] c.c.f.a.i.LocalFileConfigRepository      : Sync config from upstream repository class com.ctrip.framework.apollo.internals.RemoteConfigRepository failed, reason: Load Apollo Config failed - appId: dev, cluster: default, namespace: application, url: http://192.168.1.26:8080/configs/dev/default/application?ip=192.168.1.2 [Cause: Could not complete get operation [Cause: connect timed out]]
2021-02-01 19:02:33.628  WARN 42252 --- [ngPollService-1] c.c.f.a.i.RemoteConfigLongPollService    : Long polling failed, will retry in 1 seconds. appId: dev, cluster: default, namespaces: application, long polling url: http://192.168.1.26:8080/notifications/v2?cluster=default&appId=dev&ip=192.168.1.2&notifications=%5B%7B%22namespaceName%22%3A%22application%22%2C%22notificationId%22%3A-1%7D%5D, reason: Could not complete get operation [Cause: connect timed out]
2021-02-01 19:02:34.625  WARN 42252 --- [           main] c.c.f.a.i.RemoteConfigRepository         : Load config failed, will retry in 1 SECONDS. appId: dev, cluster: default, namespaces: application
2021-02-01 19:02:35.629  WARN 42252 --- [ngPollService-1] c.c.f.a.i.RemoteConfigLongPollService    : Long polling failed, will retry in 2 seconds. appId: dev, cluster: default, namespaces: application, long polling url: http://192.168.1.26:8080/notifications/v2?cluster=default&appId=dev&ip=192.168.1.2&notifications=%5B%7B%22namespaceName%22%3A%22application%22%2C%22notificationId%22%3A-1%7D%5D, reason: Could not complete get operation [Cause: connect timed out]
2021-02-01 19:02:36.625  WARN 42252 --- [           main] c.c.f.a.i.LocalFileConfigRepository      : Sync config from upstream repository class com.ctrip.framework.apollo.internals.RemoteConfigRepository failed, reason: Load Apollo Config failed - appId: dev, cluster: default, namespace: application, url: http://192.168.1.26:8080/configs/dev/default/application?ip=192.168.1.2 [Cause: Could not complete get operation [Cause: connect timed out]]

3.分析原因
http://192.168.1.26:8080 这个地址不是我eureka的地址,所以才找的时候会找不到

4.解决办法
启动的环境变量中加入: -Dapollo.configService=http://192.167.2.123:8080
将地址改为eureka的地址就好

你可能感兴趣的:(异常记录)