Feign builder timeouts not working

流过昼夜 提交于 2019-12-06 04:34:54

Your request options configurations are not working because you're defining an OkHttpClient, according to Feign's documentation:

OkHttpClient directs Feign's http requests to OkHttp, which enables SPDY and better network control.

So, if your OkHttpClient doesn't have defined these values, it will take defaults values, this value is 10000ms (you can find these values at line 373 here: https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/OkHttpClient.java). So, you should configure your OkHttpClient like:

OkHttpClient okHttpClient = new OkHttpClient(); okHttpClient.setConnectTimeout(timeout, TimeUnit.MILLISECONDS); okHttpClient.setReadTimeout(timeout, TimeUnit.MILLISECONDS); okHttpClient.setWriteTimeout(timeout, TimeUnit.MILLISECONDS);

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!