当前位置: 代码迷 >> 综合 >> Hystrix:Unable to connect to Command Metric Stream
  详细解决方案

Hystrix:Unable to connect to Command Metric Stream

热度:37   发布时间:2023-12-16 21:00:12.0

 版本

java.version 13
spring-boot 2.2.3.RELEASE
spring-cloud Hoxton.SR3

问题 

 

原因 

 springboot默认路径为"/"需要修改为"/hystrix.stream"

HystrixMetricsStreamServlet源码中给出通过xml配置

再springboot中我们可以采用@Bean方式配置

解决方法

增加

    @Beanpublic ServletRegistrationBean getServlet() {HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);registrationBean.setLoadOnStartup(1);registrationBean.addUrlMappings("/hystrix.stream");registrationBean.setName("HystrixMetricsStreamServlet");return registrationBean;}

或者yml文件中加入

management:enabled: falseendpoints:web:exposure:include: hystrix.streambase-path: /

重启一下ok

  相关解决方案