Issue
I'm converting the okhttp.OkHttpClient.setWriteTimeout to okhttp3.OkHttpClient.setWriteTimeout but I'm getting undefined error even with okhttp3.OkHttpClient.writeTimeout.
It's weird, but writeTimeout is in the documentation, href="https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.Builder.html#Builder--" rel="nofollow noreferrer">https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.Builder.html#Builder--
Please help.
Solution
writeTimeout() is part of okhttp3.OkHttpClient.Builder
, not okhttp3.OkHttpClient
. We could set the writeTimeout, along with proxy and any other configurations, with a single builder:
OkHttpClient client = new OkHttpClient.Builder()
.proxy(proxy)
.writeTimeout(1000, TimeUnit.MILLISECONDS)
.readTimeout(1000, TimeUnit.MILLISECONDS)
.build();
Answered By - Haoliang
Answer Checked By - Pedro (JavaFixing Volunteer)