1. 程式人生 > >通過springcloud-gateway呼叫後臺服務超時的問題

通過springcloud-gateway呼叫後臺服務超時的問題

最近有個介面需要從後臺下載檔案,下載請求會經過gateway,但是經過gateway一直都是超時的,debug了一下,發現超時時間預設是2秒。後來一直debug到原始碼,發現要增加自己相應的配置來修改超時時間。

異常如下:

{
    "timestamp": 1520236628339,
    "status": 500,
    "error": "Internal Server Error",
    "exception": "com.netflix.zuul.exception.ZuulException",
    "message": "GENERAL"
}

要增加的配置如下:

hystrix.command.hello-service.execution.isolation.thread.timeoutInMilliseconds = 60000

其中hello-service為gateway要呼叫的後臺服務ID,這裡設定超時時間為60秒。

還不太明白增加了default的配置是作用是幹嘛的?為什麼沒有生效?

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=30000

難道不應該是我沒有設定對應後臺服務的超時時間就都應該用default的設定嗎?

具體類詳見:com.netflix.hystrix.HystrixCommandProperties