Hystrix报错:Unable to connect to Command Metric Stream
检查了pom文件 和启动类的注释都没有问题 后来发现是springboot版本的问题,版本1.5之前是不需要进行配置的 但是2.x之后是需要对Hystrix进行配置的。
在hystrix-service的启动类中添加
/**
*此配置是为了服务监控而配置,与服务容错本身无关,springcloud升级后的坑
*ServletRegistrationBean因为springboot的默认路径不是"/hystrix.stream",
*只要在自己的项目里配置上下面的servlet就可以了
*/
@Bean
public ServletRegistrationBean getServlet() {
HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
registrationBean.setLoadOnStartup(1);
registrationBean.addUrlMappings("/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet");
return registrationBean;
}
只在这个启动类中添加以上代码还不行,在hystrix-service模块色yml文件中添加
management:
endpoints:
web:
exposure:
include: '
Spring Cloud高版Hystrix Dashboard连接问题及解决方案

本文主要探讨了在使用Spring Cloud较新版本时遇到的Hystrix Dashboard连接失败的问题。错误提示为'Unable to connect to Command Metric Stream'。文章指出,该问题可能由Spring Boot版本升级引起,1.5版本之前无需特别配置,但在2.x版本后需要对Hystrix进行配置。解决方案包括在Hystrix服务的启动类和yml配置文件中添加特定代码。然而,即使这样仍然可能出现控制台报错,最终解决办法是在Hystrix Dashboard模块的yml配置文件中进一步添加配置项。
最低0.47元/天 解锁文章
668





