OKHttp响应超时设置无效

添加retryConnectFailure参数,如下:

OkHttpClient client = new OkHttpClient.Builder()
                    .connectTimeout(5, TimeUnit.SECONDS)
                    .readTimeout(5, TimeUnit.SECONDS)
                    .retryOnConnectionFailure(false)
                    .build();

设置retryOnConnectionFailure(false)即可。

该问题在3.4.1之后的版本已解决

https://github.com/square/okhttp/issues/2756

你可能感兴趣的:(OKHttp响应超时设置无效)