[Sentinel] The console sends a heartbeat packet error (9)

前言

Reprinted: https://www.jianshu.com/p/8ecb898ef315 The
sentinel console sends a heartbeat packet error:

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)

解决办法

The solution:
replace the sentinel-transport-simple-httpdependency withsentinel-transport-netty-http包

<dependency>
    <groupId>com.alibaba.csp</groupId>
    <artifactId>sentinel-transport-netty-http</artifactId>
    <version>x.y.z</version>
</dependency>

测试

First of all, before modifying the dependency, you can modify the heartbeat port and heartbeat period when jnm starts. In this way, you can clearly see the error message of the currently debugged project.
Then replace the dependencies, restart the project, and you can see that the error log previously displayed on the console is gone.
The configuration is as follows:

  • The port number for starting the HTTP API Server locally (that is, the heartbeat address port of the current service)
    -Dcsp.sentinel.api.port=8206
  • Heartbeat packet sending cycle, in milliseconds
    -Dcsp.sentinel.heartbeat.interval.ms=2000

总结

Because I have multiple services here, when I modified this question, I first modified two services. At this time, it was discovered that the two modified services no longer displayed the error message of the heartbeat packet, and only the third one that was not modified was still prompted.
But the heartbeat interval I set is once every two seconds, the error message is once every 6 seconds (You can refer to the console log information at the top). So you can know that the console sends heartbeats one by one

Guess you like

Origin blog.csdn.net/s1441101265/article/details/107688324