Hystrix icon indicating copy to clipboard operation
Hystrix copied to clipboard

Unable to connect to Command Metric Stream

Open AshutoshSharma10 opened this issue 7 years ago • 39 comments

Hi,

We are using the Spring boot starter parent 1.5.2.RELEASE and hystrix 1.5.6 dependencies. Fortunately it works once in hundred tries. We are really puzzled, why it works once and then never. All the services are running on the local machine. The log details are as below: Proxy opening connection to: http://localhost:6001/hystrix.stream 2017-05-05 12:29:16.951 INFO 4876 --- [nio-6001-exec-5] ashboardConfiguration$ProxyStreamServlet : Proxy opening connection to: http://localhost:6001/hystrix.stream 2017-05-05 12:31:36.163 INFO 4876 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration

We are using the actuator also and tried the management.port once but the result is same. So we removed it. The same thing we tried with turbine and it also behaves the same way.

Please suggest.

Below is the resulting screen: image

AshutoshSharma10 avatar May 05 '17 07:05 AshutoshSharma10

@AshutoshSharma10 Could you please create sample project which simulates the above problem. Is the server polling the data?

mohanaraosv avatar May 08 '17 09:05 mohanaraosv

@AshutoshSharma10 It's very difficult to provide an answer with those details. One possible way of getting to the bottom of it would be for you to look at the sample application that properly serves the metrics stream, and find out where yours differs.

https://github.com/Netflix/Hystrix/tree/master/hystrix-examples-webapp

mattrjacobs avatar May 09 '17 22:05 mattrjacobs

I want to plus this issue -- we are seeing the same issue with Spring-boot 1.4.x and not just 1.5.x.

If we try to curl the end point instead of getting back a snapshot of data, we get

Previous versions of Spring-boot 1.3.x did not have an issue. At first sight, this seems to be an incompatibility with Spring-boot or one of it's dependencies since our team had not had issues until a recent upgrade with Hystrix.

Noteworthy comment is that all other parts of Hystrix are working just fine. RequestLog, and at least Circuit Breaking are working as designed. For some reason the Hystrix Streaming Servlet is no longer functional for us.

Is there any way to troubleshoot this issue?

The symptoms we receive for this issue are as follows:

  • Unable to connect to Command Stream (per description of ticket)
  • Access log receives 503 http status entry for hystrix.stream end point
  • The curl below hangs:
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET /debug/hystrix.stream HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.51.0
> Accept: */*
>```

michelbetancourt avatar May 11 '17 18:05 michelbetancourt

If time permits we will try to put together a sandbox sample app, if one is not already provided.

michelbetancourt avatar May 11 '17 18:05 michelbetancourt

Found the issue on our end. We added a delay in the writing of the response so that we can propagate headers in our response the way we needed them. Hystrix Servlet does not play well with our Response-delaying mechanism.

michelbetancourt avatar May 11 '17 19:05 michelbetancourt

Hello,

We are also having a spring boot app and trying to see the metrics on the hystrix dashboard, But getting exactly the same issue. Is there any update on this issue. We are using hystrix 1.5.3. Any fix or workaround would be helpful Thanks in Advance

615Manu avatar Jun 03 '17 08:06 615Manu

@615Manu The original issue was resolved. Every circumstance is potentially different, and you haven't listed any details about your problem.

I would start by looking at the sample application that properly serves the metrics stream, and find out where yours differs.

https://github.com/Netflix/Hystrix/tree/master/hystrix-examples-webapp

mattrjacobs avatar Jun 11 '17 16:06 mattrjacobs

@615Manu @AshutoshSharma10 For spring boot apps to show Hystrix metrics, the spring starter spring-boot-starter-actuator should be added to your dependency. This will apparently enable the metrics filter.

Also, make sure you open the http://<host>:<port>/hystrix/monitor URL and type http://<host>:<port>/hystrix.stream in the textbox. Then hit the Monitor Stream button to see the live stats.

asgs avatar Aug 24 '17 12:08 asgs

i also encountered the same problem ,and the version is 1.4.3

sunday2 avatar Feb 28 '18 01:02 sunday2

I have the same question...version is 2.0

Credo-Zhao avatar Mar 07 '18 04:03 Credo-Zhao

management.endpoints.web.exposure.include=* adding in application.properties solved for me

tomfrans avatar Mar 17 '18 18:03 tomfrans

This isn't the spring cloud Netflix repository

spencergibb avatar Mar 17 '18 19:03 spencergibb

same question , version 2.0.0 ,
http://localhost:8764/hystrix.stream get the same page with http://localhost:8764/hystrix

ezhong0812 avatar Mar 20 '18 04:03 ezhong0812

This isn't the spring cloud Netflix repository

spencergibb avatar Mar 20 '18 05:03 spencergibb

version 2.0.0. "management.endpoints.web.exposure.include=hystrix.stream" adding in bootstrap.properties; and the url was change to "http://host:port/actuator/hystrix.stream", it is ok. also,"management.endpoints.web.base-path=/ " can make "http://host:port/hystrix.stream" work.

cion-J avatar Mar 26 '18 09:03 cion-J

@cion-J Yours answer solved for me! thks!

moviewang avatar Apr 03 '18 06:04 moviewang

hi,i just occured this problem,after one day, i may have solved this,please add a class in your project

version:2.0

package com.sc.consumerribbon.config;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;

@Configuration public class HystrixServletDefinitions {

@Bean(name = "hystrixRegistrationBean")
public ServletRegistrationBean servletRegistrationBean() {
    ServletRegistrationBean registration = new ServletRegistrationBean(
            new HystrixMetricsStreamServlet(), "/hystrix.stream");
    registration.setName("hystrixServlet");
    registration.setLoadOnStartup(1);
    return registration;
}

} @AshutoshSharma10 可以看下我记录的 https://blog.csdn.net/qq_22772259/article/details/79812026

ww530220264 avatar Apr 04 '18 01:04 ww530220264

@ww530220264 Thanks guy, I have solved this problem in my project with your method.

1029574707 avatar Apr 20 '18 09:04 1029574707

@ww530220264 Thanks for a lot,your method is great.

playerlilin avatar Apr 26 '18 05:04 playerlilin

The above solution is for 2.0.x. However it's still not working with Spring-boot 1.4.x and 1.5.x. Any updates on that?

rajeshrengarajulu avatar Apr 27 '18 19:04 rajeshrengarajulu

This isn't the spring cloud Netflix repository

spencergibb avatar Apr 27 '18 20:04 spencergibb

this solution is great , so may be is a miss part of cloud document? thanks @ww530220264

duanhaowei avatar May 05 '18 09:05 duanhaowei

Solution from @cion-J is great! Spring Cloud docs require minor adjustment to reflect the change. My suggested PR: https://github.com/kennyk65/spring-cloud-netflix/pull/1

kennyk65 avatar Jun 22 '18 02:06 kennyk65

spring cloud doc is really sucks...

ghost avatar Jul 12 '18 09:07 ghost

just added one class as below : @Configuration public class HystrixServletDefinitions { @Bean(name = "hystrixRegistrationBean") public ServletRegistrationBean servletRegistrationBean() { ServletRegistrationBean registration = new ServletRegistrationBean( new HystrixMetricsStreamServlet(), "/metrics/hystrix.stream"); registration.setName("hystrixServlet"); registration.setLoadOnStartup(1); return registration; } }

issues resolved.

lennyxue avatar Aug 23 '18 10:08 lennyxue

if there was no HystrixCommand data , the hystrix server log "java.net.SocketTimeoutException: Read timed out" . it also show you "Unable to connect to Command Metric Stream" on the dashboard .
so you can request the HystrixCommad .then it will be ok the detail info in HystrixSampleSseServlet.handleRequest() image

MrSummer33 avatar Sep 04 '18 13:09 MrSummer33

version 2.0.0. "management.endpoints.web.exposure.include=hystrix.stream" adding in bootstrap.properties; and the url was change to "http://host:port/actuator/hystrix.stream", it is ok. also,"management.endpoints.web.base-path=/ " can make "http://host:port/hystrix.stream" work.

I have the same problem and the solution above works for me! Look very strange and not user-friendly...

romankh3 avatar Sep 28 '18 07:09 romankh3

For me on Spring-Boot version 2 helped with dependencies

        <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>

Added anotation to aplication @EnableHystrixDashboard Added bootstrap poperties (not sure why in some examples they are not using or why are they using here)

management:
  endpoints:
    web:
      exposure:
        include: hystrix.stream
      base-path: /

Run the app Opened first http://host:port/hystrix then added in the url http://host:port/hystrix.stream and it worked If I used http://host:port/actuator/hystrix.stream I was getting errors

BroniusJanonis avatar Oct 01 '18 10:10 BroniusJanonis

version 2.0.0. "management.endpoints.web.exposure.include=hystrix.stream" adding in bootstrap.properties; and the url was change to "http://host:port/actuator/hystrix.stream", it is ok. also,"management.endpoints.web.base-path=/ " can make "http://host:port/hystrix.stream" work.

This worked for me, thank you!!

rajanikanthbhagavan avatar Feb 09 '19 21:02 rajanikanthbhagavan

You should add both @EnableHystrixDashboard and @EnableCircuitBreaker

like this:

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableHystrixDashboard
@EnableCircuitBreaker
public class ConsumerApplication {
	public static void main(String[] args) {
		SpringApplication.run(ConsumerApplication.class, args);
	}
}

Sicmatr1x avatar Mar 20 '19 09:03 Sicmatr1x