1. 程式人生 > >解決com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method Tried 3 times of the providers 錯誤

解決com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method Tried 3 times of the providers 錯誤

2018-08-29  小賴   文件初始化

解決com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method newModel in the service com.xxx.service.xxx. Tried 3 times of the providers 錯誤

使用dubbo生產者註冊服務,消費者去使用時報上述錯誤,在確認生產者確實提供了該服務後,檢視是否是別的原因。消費者訪問了三次,打斷點確實進入了生產者提供的服務,但是消費者那邊快速失敗了。

資料顯示:dubbo的DEFAULT_TIMEOUT
請求執行預設超時時間 1s ,那就是說生產者如果1s還沒有響應消費者,那麼消費者就會再次傳送請求,這是產生了三次請求的原因 Tried 3 times of the providers

;這樣的話我們只要設定請求執行超時時間就可以解決這個問題了。

解決方案:在dubbo.xml配置檔案中增加 <dubbo:provider delay="-1" timeout="6000" retries="0”/> ;合理設定超市時間就可以了。