zuul 超时 504,不触发服务熔断进行降级是为什么?

zuul 超时 504,不触发服务熔断进行降级是为什么?
图片说明
正常访问 http://localhost:8081/ribbon6 可以触发 Hystrix

网上说配置
##socket超时
zuul.host.socket-timeout-millis=3000
#HTTP连接超时要比Hystrix的大
zuul.host.connect-timeout-millis=10000

结果超时还是504 错误

    //服务熔断
    @HystrixCommand(fallbackMethod="helloFallback")
    public String helloService() throws InterruptedException {
        ResponseEntity<String> responseEntity = restTemplate.getForEntity("http://eureka-server/helloParam?username={1}", String.class, "didi");
        String body = responseEntity.getBody();
        //让处理线程等待几秒钟
        int sleepTime= new Random().nextInt(4000);
//      int sleepTime=3000;
        logger.info("sleepTime:" + sleepTime);
        Thread.sleep(sleepTime);
        logger.info("/hello, host:" + registration.getHost() + ", service id:" +registration.getServiceId());
        return body;    
    }


     //服务降级
     public String helloFallback() {
            return "error";
     }

消费者配置

#多实例配置
zuul.routes.hello-service.path=/hello-service/**
zuul.routes.hello-service.serviceId=hello-service
ribbon.eureka.enabled=false 
hello-service.ribbon.listOfServers=http://localhost:8080/,http://localhost:8082/
##socket超时
zuul.host.socket-timeout-millis=3000
#HTTP连接超时要比Hystrix的大
zuul.host.connect-timeout-millis=10000

2个回答

解决了。。


#单实例配置1 路由转发
zuul.routes.eureka-server-1.path=/eureka-server-1/**
zuul.routes.eureka-server-1.url=http://localhost:8080/
#单实例配置2 路由转发
zuul.routes.eureka-server-2.path=/eureka-server-2/**
zuul.routes.eureka-server-2.url=http://localhost:8082/

#多实例配置 负载均衡 路由转发
zuul.routes.eureka-server-3.path=/eureka-server-3/**
zuul.routes.eureka-server-3.serviceId=eureka-server
eureka-server-3.ribbon.listOfServers=http://localhost:8080/,http://localhost:8082/

不是已经返回error页面了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐