通過API網關路由來訪問用戶服務,zuul默認路由規則 :http://zuul的Host地址:zuul端口/要調用的服務名/服務方法地址
瀏覽器中打開http://127.0.0.1:8000/wallet/system/hello/1
報錯:
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Aug 07 17:49:01 CST 2018
There was an unexpected error (type=Gateway Timeout, status=504).
com.netflix.zuul.exception.ZuulException: Hystrix Readed time out
這個錯誤是應為zuul的默認超時時間比較小,我們配置下zuul的超時時間,因zuul啟用了ribbon的負載均衡,還需要設置ribbon的超時時間,注意ribbon的超時時間要小於zuul超時時間 。
zuul: host: connect-timeout-millis: 15000 #HTTP連接超時要比Hystrix的大 socket-timeout-millis: 60000 #socket超時 ribbon: ReadTimeout: 10000 ConnectTimeout: 10000
qq群:216868740