在Spring Cloud中加入Hystrix和Hystrix Dashboard,在触发熔断生效之后,使用Hystrix Dashboard来查看具体状态信息,进入页面后提示Unable to connect to Command Metric Stream,那我们按照如下方式来解决。
Spring cloud版本:Greenwich.SR2
Spring Boot版本:2.1.6.RELEASE
只需在项目中配置一下这个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;
}
加入后,重启测试,一切正常
可以去这里看一下具体原因(传送门:https://blog.csdn.net/ddxd0406/article/details/79643059)