温疫流行,家中休息期间,再次进行微服务分布架构,HystrixDashboard图表化hystrix/turbine.stream,大部分情况不能获取数据,指示Unable to connect to Command Metric Stream

HystrixDashboard图表化hystrix/turbine.stream问题探索

之前,调试通过的。spring boot版本2.2.4。于是按惯例为加入HystrixMetricsStream的Servlet

    @Bean
    public ServletRegistrationBean<HystrixMetricsStreamServlet> getServlet() {
         HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
         ServletRegistrationBean<HystrixMetricsStreamServlet> registrationBean = new ServletRegistrationBean<HystrixMetricsStreamServlet>(streamServlet);
         registrationBean.setLoadOnStartup(1);
         registrationBean.addUrlMappings("/actuator/hystrix.stream");
         registrationBean.setName("HystrixMetricsStreamServlet");
         return registrationBean;
    }

依然无效。

相关服务已经经过调用,不存在没有操控而一直loading的状态:

HystrixDashboard图表化hystrix/turbine.stream问题探索

此时控制台显示:

HystrixDashboard图表化hystrix/turbine.stream问题探索

浏览器调试页面指示:

HystrixDashboard图表化hystrix/turbine.stream问题探索

问题点:EventSource's response has a MIME type ("text/plain") that is not "text/event-stream". Aborting the connection.

查阅HystrixDashboard的jar包的页面模板文件,它采用了HTML5的EventSource服务端推送机制实现数据刷新:

HystrixDashboard图表化hystrix/turbine.stream问题探索

反汇编源码的纠结点处:

HystrixDashboard图表化hystrix/turbine.stream问题探索

于是在MIME类型变换"text/plain"到"text/event-stream"上多次设法修正,依然无果。

深入查阅HystrixMetricsStreamServlet相关的源码HystrixSamlpleSseServlet:

HystrixDashboard图表化hystrix/turbine.stream问题探索

也没有发现有不合适的操作。

疫情缓解,复工上班,将框架源码带回台式机试验,竞完全可以运行起来,而且不考虑所说的HystrixMetricsStream的Servlet,也没有问题:

HystrixDashboard图表化hystrix/turbine.stream问题探索

在笔记本电脑上依然不可以运行。差别:笔记本电脑的开发环境版本相对高些,不应该是这个原因吧,进一步探索中...

相关文章:

  • 2021-11-08
  • 2021-11-16
  • 2021-11-10
  • 2021-08-17
  • 2022-01-04
  • 2022-01-12
  • 2021-12-23
  • 2021-06-11
猜你喜欢
  • 2021-05-16
  • 2021-05-08
  • 2021-04-30
  • 2021-11-05
  • 2021-06-09
  • 2022-01-12
相关资源
相似解决方案