可能大家看到这篇博客的时候已经查看了各种博客,因为解决2.3.3和2.3.1版本的这种异常的现阶段比较少,所以降版本可能是最好的选择,但是高版本总得有人来踩坑,今天我就带来一种行之有效的解决方法
因为2.3.3和2.3.1是较为新的版本,可是一代版本一代bug接下来就是关于2.3.3和2.3.1版本的Unable to connect to Command Metric Stream.异常处理
之前的基础配置先弄好
1.依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<!-- 健康监控模块-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
2.主类注解@EnableHystrixDashboard
3.yml配置文件
feign:
hystrix:
enabled: true #默认false
management:
endpoints:
web:
exposure:
include: "*"# 访问/actuator/hystrix.stream能看到不断更新的监控流
基本的弄好后重点来了
yml配置文件再加上
hystrix:
dashboard:
proxy-stream-allow-list: "*"
主类加上
@Bean
public ServletRegistrationBean getServlet(){
HystrixMetricsStreamServlet hystrixMetricsStreamServlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(hystrixMetricsStreamServlet);
servletRegistrationBean.setLoadOnStartup(1);
servletRegistrationBean.setUrlMappings(Arrays.asList("/hystrix.stream"));
servletRegistrationBean.setName("HystrixMetricsStreamServlet");
return servletRegistrationBean;
}