zoukankan      html  css  js  c++  java
  • Gateway 访问超时 返回504

    问题梳理

    【现象】Gateway访问超时
    {
        "timestamp": "2019-06-29 11:45:13",
        "path": "/admin/user/info",
        "status": 504,
        "error": "Gateway Timeout",
        "message": "Response took longer than configured timeout"
    }
    
    【方法】 根据出错位置查看源代码,

    AbstractCommand->

    HystrixObservableTimeoutOperator->

    final Reference tl = HystrixTimer.getInstance().addTimerListener(listener);

    1. 看到有时间监听类
    public Reference<TimerListener> addTimerListener(final TimerListener listener) {
            startThreadIfNeeded();
            // add the listener
    
            Runnable r = new Runnable() {
    
                @Override
                public void run() {
                    try {
                        listener.tick();
                    } catch (Exception e) {
                        logger.error("Failed while ticking TimerListener", e);
                    }
                }
            };
    
            ScheduledFuture<?> f = executor.get().getThreadPool().scheduleAtFixedRate(r, listener.getIntervalTimeInMilliseconds(), listener.getIntervalTimeInMilliseconds(), TimeUnit.MILLISECONDS);
            return new TimerReference(listener, f);
        }
    

    2.找到关键点

        listener.getIntervalTimeInMilliseconds()
    

    3.接着看lister的实现

            @Override
            public int getIntervalTimeInMilliseconds() {
                return properties.timerDelayInMilliseconds().get();
            }
    
    

    4.找到properties关键类

    HystrixCollapserProperties
    

    5.终于找到了关键属性

    timerDelayInMilliseconds
    
     protected HystrixCollapserProperties(HystrixCollapserKey key, Setter builder, String propertyPrefix) {
            this.maxRequestsInBatch = getProperty(propertyPrefix, key, "maxRequestsInBatch", builder.getMaxRequestsInBatch(), default_maxRequestsInBatch);
            this.timerDelayInMilliseconds = getProperty(propertyPrefix, key, "timerDelayInMilliseconds", builder.getTimerDelayInMilliseconds(), default_timerDelayInMilliseconds);
            this.requestCacheEnabled = getProperty(propertyPrefix, key, "requestCache.enabled", builder.getRequestCacheEnabled(), default_requestCacheEnabled);
            this.metricsRollingStatisticalWindowInMilliseconds = getProperty(propertyPrefix, key, "metrics.rollingStats.timeInMilliseconds", builder.getMetricsRollingStatisticalWindowInMilliseconds(), default_metricsRollingStatisticalWindow);
            this.metricsRollingStatisticalWindowBuckets = getProperty(propertyPrefix, key, "metrics.rollingStats.numBuckets", builder.getMetricsRollingStatisticalWindowBuckets(), default_metricsRollingStatisticalWindowBuckets);
            this.metricsRollingPercentileEnabled = getProperty(propertyPrefix, key, "metrics.rollingPercentile.enabled", builder.getMetricsRollingPercentileEnabled(), default_metricsRollingPercentileEnabled);
            this.metricsRollingPercentileWindowInMilliseconds = getProperty(propertyPrefix, key, "metrics.rollingPercentile.timeInMilliseconds", builder.getMetricsRollingPercentileWindowInMilliseconds(), default_metricsRollingPercentileWindow);
            this.metricsRollingPercentileWindowBuckets = getProperty(propertyPrefix, key, "metrics.rollingPercentile.numBuckets", builder.getMetricsRollingPercentileWindowBuckets(), default_metricsRollingPercentileWindowBuckets);
            this.metricsRollingPercentileBucketSize = getProperty(propertyPrefix, key, "metrics.rollingPercentile.bucketSize", builder.getMetricsRollingPercentileBucketSize(), default_metricsRollingPercentileBucketSize);
        }
    

    Gateway的超时是通过Hystrix的属性控制的Orz

    方向错了,赶紧换个方向

    https://www.cnblogs.com/520playboy/p/8074347.html

    总结

    一直想找Gateway的属性,试了半天,网上各种找都没找到,最后还是通过看源码,发现方向错误了,调整方向,bingo.

  • 相关阅读:
    【Navicat】查看历史执行的SQL
    什么是webpack模块化构建工具
    靠边的列表如果没有设置margin-left:20px,那么是看不到列表序号的。
    在博客园中复制代码到网页中,有时候会存在异常,如下:
    / WebAPP开发与小程序 / 步骤一 · 4-5 地图搜索与poi结合(2)
    忘记样式属性对应的值时,可以使用以下方法进行操作
    //点击按钮加减音频音量到最小会出现bug什么意思???
    组件化网页开发 3步骤 / 20门课
    position:absolute 按钮左右分布:left:0 和 right:0 以及雪碧图
    查看引入的文件是否成功
  • 原文地址:https://www.cnblogs.com/mengjianzhou/p/11106221.html
Copyright © 2011-2022 走看看