【sentinel】控制台发送心跳包报错

前言

转载:https://www.jianshu.com/p/8ecb898ef315
sentinel控制台发送心跳包报错:

2020-07-30 13:40:57.720 ERROR 19940 --- [pool-4-thread-1] c.a.c.s.dashboard.metric.MetricFetcher   : Failed to fetch metric from <http://192.168.17.46:8725/metric?startTime=1596087648000&endTime=1596087654000&refetch=false> (ConnectionException: Connection refused: no further information)
2020-07-30 13:41:04.718 ERROR 19940 --- [pool-4-thread-1] c.a.c.s.dashboard.metric.MetricFetcher   : Failed to fetch metric from <http://192.168.17.46:8725/metric?startTime=1596087655000&endTime=1596087661000&refetch=false> (ConnectionException: Connection refused: no further information)
2020-07-30 13:41:11.719 ERROR 19940 --- [pool-4-thread-1] c.a.c.s.dashboard.metric.MetricFetcher   : Failed to fetch metric from <http://192.168.17.46:8725/metric?startTime=1596087662000&endTime=1596087668000&refetch=false> (ConnectionException: Connection refused: no further information)
2020-07-30 13:41:18.719 ERROR 19940 --- [pool-4-thread-1] c.a.c.s.dashboard.metric.MetricFetcher   : Failed to fetch metric from <http://192.168.17.46:8725/metric?startTime=1596087669000&endTime=1596087675000&refetch=false> (ConnectionException: Connection refused: no further information)
2020-07-30 13:41:25.718 ERROR 19940 --- [pool-4-thread-1] c.a.c.s.dashboard.metric.MetricFetcher   : Failed to fetch metric from <http://192.168.17.46:8725/metric?startTime=1596087676000&endTime=1596087682000&refetch=false> (ConnectionException: Connection refused: no further information)
2020-07-30 13:41:32.718 ERROR 19940 --- [pool-4-thread-1] c.a.c.s.dashboard.metric.MetricFetcher   : Failed to fetch metric from <http://192.168.17.46:8725/metric?startTime=1596087683000&endTime=1596087689000&refetch=false> (ConnectionException: Connection refused: no further information)
2020-07-30 13:41:39.732 ERROR 19940 --- [pool-4-thread-1] c.a.c.s.dashboard.metric.MetricFetcher   : Failed to fetch metric from <http://192.168.17.46:8725/metric?startTime=1596087690000&endTime=1596087696000&refetch=false> (ConnectionException: Connection refused: no further information)
2020-07-30 13:41:46.730 ERROR 19940 --- [pool-4-thread-1] c.a.c.s.dashboard.metric.MetricFetcher   : Failed to fetch metric from <http://192.168.17.46:8725/metric?startTime=1596087697000&endTime=1596087703000&refetch=false> (ConnectionException: Connection refused: no further information)
2020-07-30 13:41:53.728 ERROR 19940 --- [pool-4-thread-1] c.a.c.s.dashboard.metric.MetricFetcher   : Failed to fetch metric from <http://192.168.17.46:8725/metric?startTime=1596087704000&endTime=1596087710000&refetch=false> (ConnectionException: Connection refused: no further information)

解决办法

解决办法:
sentinel-transport-simple-http依赖换成sentinel-transport-netty-http包

<dependency>
    <groupId>com.alibaba.cspgroupId>
    <artifactId>sentinel-transport-netty-httpartifactId>
    <version>x.y.zversion>
dependency>

测试

首先,在没修改依赖前,可以修改下jnm启动时,心跳端口和心跳周期。这样可以清楚的看到当前调试的项目报错信息。
然后替换依赖,重启项目,就可以看到,控制台之前显示的错误日志已经没了。
配置如下:

  • 本地启动 HTTP API Server 的端口号(就是当前服务的心跳地址端口)
    -Dcsp.sentinel.api.port=8206
  • 心跳包发送周期,单位毫秒
    -Dcsp.sentinel.heartbeat.interval.ms=2000

总结

因为我这边是有多个服务,我修改这个问题的时候,先是修改了两个服务。这时候发现,修改过的这两个服务没有再显示心跳包的报错信息了,只有第三个没有修改的依然在提示。
但是我设置的心跳间隔是两秒1次,这个报错的信息却是6秒1次(可以参考最上面的控制台日志信息)。所以可以知道,控制台发送心跳是一个一个发的

你可能感兴趣的:(spring,cloud)